Page 1 of 1

Loop on Months at Sequence

Posted: Mon Jan 26, 2015 10:15 am
by sohasaid
Hi,

I have my data source as sequential files. They are monthly files with such a file name structure 'KPI_20140501.txt'. The requirement is to load multiple months during one run. The input parameter is DateFrom & DateTo.

I have daily files and in order to loop on them for a week for example, I'm converting the input DateFrom & DateTo to Iconv format then looping on them by incrementing one.

I want to apply the same logic for monthly files, but have no clue how to loop on months as converting them to Iconv won't fix the issue.

For example, how to loop on below files three times only? (Days are always fixed to '01')
KPI_20140501.txt
KPI_20140601.txt
KPI_20140701.txt

Parameters:
DateFrom Parameter is '2014-05-01'
DateTo Parameter is '2014-07-01'

Regards

Posted: Mon Jan 26, 2015 2:18 pm
by qt_ky
If the day number is always fixed at '01' then you could still use Iconv() to convert to an internal number and add 31. The result would always be the next month. Use Oconv() to convert the result back to an external date format, and then discard the day number and concat day number 01. Iterate until the final result matches the DateTo value.

Posted: Tue Jan 27, 2015 5:58 am
by sohasaid
Simple & efficient . It has worked perfectly :)

Thanks, Eric