Generate Dates between 2 Dates

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
poorna_76
Charter Member
Charter Member
Posts: 190
Joined: Thu Jul 08, 2004 10:42 am

Generate Dates between 2 Dates

Post by poorna_76 »

Hi All,

I have a requirement where i need to generate all the dates between 2 given dates.

I need to do a lookup against HolidaysList for that generated list and also need to exclude Saturdays & Sundays.


Any thoughts on how we can implement this?

Thanks in Advance.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Should be pretty straight-forward. A job that starts with a Transformer and a hashed file with Holidays in it would get you what you need.

Job parameters could control the start and end date ranges. Create a bogus Stage Variable so the job will compile but you don't (necessarily) need to use it. Convert the dates to internal format so you can simply add 1 to increment a day at a time. There are other transforms to get the 'day number' for each generated date so that you skip any holidays or weekend dates. Then only output valid dates until you exceed the ending date parameter, control that via a constraint. Convert back to external format on the way out in the appropriate format for your target.
-craig

"You can never have too many knives" -- Logan Nine Fingers
poorna_76
Charter Member
Charter Member
Posts: 190
Joined: Thu Jul 08, 2004 10:42 am

Post by poorna_76 »

Thanks Chulett, that helps.
dsnovice
Participant
Posts: 38
Joined: Thu Jul 22, 2004 11:56 pm
Location: Mclean, VA
Contact:

Re: Generate Dates between 2 Dates

Post by dsnovice »

If your main requirement is to find out the number of days between any two given days .
I would say from your calendar table take in all the days starting from Day 1 determine whether its an holiday or a week end. If not then give it a count 1. then keep on incrementing this work day count accordingly. Load the Calendar date and work day count into an hash file.

Then when you come up with the two dates you can look them up and calculate the difference in the transformer.

IHTH.

two cents
Post Reply