Loop on Months at Sequence

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
sohasaid
Premium Member
Premium Member
Posts: 115
Joined: Tue May 20, 2008 3:02 am
Location: Cairo, Egypt

Loop on Months at Sequence

Post 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
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post 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.
Choose a job you love, and you will never have to work a day in your life. - Confucius
sohasaid
Premium Member
Premium Member
Posts: 115
Joined: Tue May 20, 2008 3:02 am
Location: Cairo, Egypt

Post by sohasaid »

Simple & efficient . It has worked perfectly :)

Thanks, Eric
Post Reply