Date calculation - Logic required

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
savis
Premium Member
Premium Member
Posts: 27
Joined: Tue Apr 15, 2008 11:06 pm

Date calculation - Logic required

Post by savis »

Whenever I run the job, the start date and end date should be generated based on the current date.

If I run the job on (Date: 06/01/09 ), then Load the data for 7 Months
Current Month + Next 3 Months : Jun + Jul, Aug, Sept 09
Previous 3 Months : Mar, Apr, May 09
Start date : Mar -01 - 2009
End Date : Sep - 30-2009

If I run the job on (Date: 06/02/09 ), then Load the data for 7 Months
Current Month + Next 3 Months : Jun + Jul, Aug, Sept 09
Previous 3 Months : Mar, Apr, May 09
Start date : Mar -01 - 2009
End Date : Sep - 30-2009

If I run the job on (Date: 07/01/09 ), then Load the data for 7 Months
Current Month + Next 3 Months : Jul + Aug, Sept, Oct 09
Previous 3 Months : Apr, May, Jun 09
Start date : APr -01 - 2009
End Date : Oct - 31-2009

Note: Start date should be first date of the previous third month
and end date should be the last date of the next third month.
(This excludes the current month and should always pull 7 months data).

I am not sure how to do it.

Please help
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use the AddMonthsToDate() routine from here to calculate a start date and end date, then use MONTH.FIRST and MONTH.LAST transforms.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply