Page 1 of 1

Adding the Month

Posted: Thu Dec 13, 2007 9:34 am
by somu_june
Hi,


I have a requirement like this . I need to add a month from input date which Iam getting as varchar (8) . For example 20071201 it must be 20080101 and it must take care of leap years also . Can some body help me in this.


Thanks,
Somaraju.

Posted: Thu Dec 13, 2007 9:40 am
by DSguru2B
You will have to create your own, nothing is provided out of the box.

Posted: Thu Dec 13, 2007 2:39 pm
by JoshGeorge
FLOOR(No_Of_Months/12) will give you years to be added/subtracted and
(No_Of_Months MOD 12) will give you months to be added/subtracted

This should give you the lead to your solution. A solution to subtract months is given in this LINK, tweak this code if you want to add, won't be that difficult.

Posted: Fri Dec 14, 2007 4:24 pm
by paddu
Do exact Search on "AddMonths routine" ,you may find some ways to achieve your requirement.


Paddu