Page 1 of 1

How To find the previous month??

Posted: Thu Jan 17, 2008 9:28 pm
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??

Posted: Thu Jan 17, 2008 10:18 pm
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.

Re: How To find the previous month??

Posted: Thu Jan 17, 2008 10:29 pm
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?