Page 1 of 1

Date calculation

Posted: Thu Feb 22, 2007 12:28 am
by mydsworld
How do we find the start & end date of next month or previous month.Is there any function to do that.

Posted: Thu Feb 22, 2007 1:02 am
by kumar_s
There is, but you should have done a search before that.
Last date of the previous month -

Code: Select all

DateFromDaysSince(-1, StringToDate(RUN_DT, "%yyyy%mm") : "%yyyy-%mm-%dd") 
And First day of the previous month -

Code: Select all

StringToDate('01':MonthFromDate(RUN_DT,"yyyy%mm%dd")-1,YearFromDate(RUN_DT,"yyyy%mm%dd"))
Here RUN_DT is in yyyy%mm%dd.

And its better to use a stage variable for Month and Year, so the calculatin for December and January can be taken care with If - Then - Else.

Re: Date calculation

Posted: Thu Feb 22, 2007 2:21 am
by venkycool
Yeah Kumar is right and the code is also correct. create a stage variable for date and then give the derivations.