How To find the previous month??

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
SHARAD123
Premium Member
Premium Member
Posts: 54
Joined: Wed Jan 09, 2008 12:05 am

How To find the previous month??

Post by SHARAD123 »

I got a job which prompts for the day of run... If no value is passed it should take the previous month's date... how to get that??
222102
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

If @MONTH = 1 Then (Oconv(@DATE,"DY") - 1) : "-12-" : Oconv(@DATE,"DD") Else Oconv(@DATE,"DY") : "-" : (Oconv(@DATE,"DM") - 1) : "-" : Oconv(@DATE,"DD")
Some further tidying up is necessary if today's day number in the month is illegal for the previous month, but the above will get you going. In the Else clause you just need extra If tests on @MONTH.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vrishabhsagar
Participant
Posts: 33
Joined: Mon Nov 12, 2007 1:02 am
Location: Bangalore

Re: How To find the previous month??

Post by vrishabhsagar »

SHARAD123 wrote:I got a job which prompts for the day of run... If no value is passed it should take the previous month's date... how to get that??
For any such activities, I usually employ scripts and use command stage at sequencer level to implement the logic. Your scripts can return values to the jobs as parameters.

Can you give some more information, of what exactly u mean by previous month's date? and day of run?
Rishabh Sagar V
Bangalore
Post Reply