October 14, 2005, 07:49 AM
shashiAdding a month to a date
I am declaring a variable like
-SET &PER_START = 20051001;
Then I need to add a month to that date,so it has to show the date like 20051101.Then i need to substract one day from the above output,it bring back the end date of previous month(20051031).
I used the Dateadd,but its not working.
can any one suggest me as soon as possible.
October 14, 2005, 12:35 PM
codermonkeyThere are a lot of posts here about date arithmetic. But, since you are in a hurry, I think this will get you what you need:
-SET &PER_START = 20051001;
-SET &DTE_NXT=DATECVT((DATEADD((DATECVT(&PER_START,'I8YYMD','YYMD')),
- 'M',1)), 'YYMD', 'I8YYMD');
-SET &DTE_END=DATECVT((DATEADD((DATECVT(&DTE_NXT,'I8YYMD','YYMD')),
- 'D',-1)), 'YYMD', 'I8YYMD');
-*
-TYPE &PER_START
-TYPE &DTE_NXT
-TYPE &DTE_END
October 14, 2005, 02:02 PM
susannahuse the AYM function