Page 1 of 1

Posted: Mon Aug 05, 2002 12:34 am
by WoMaWil
Hi Santosh,

If all your dates are in the way you showed you can devide the date in two partial strings:
one for the year: MyYear=MyDate[4]
and one for the Rest MyRest=Mydate[1,7]
then you add one to the year: MyYear+=1
and you put the parts together: MyNewDate=MyRest:MyYear
That's it!

Wolfgang

I am trying to add 1 to an year part of the date field.
eg. 20-JAN-1998 + 1 = 20-JAN-1999.
Any suggestions on doing this in a simplified way.

Thanks in advance

Santosh




Posted: Mon Aug 05, 2002 8:21 am
by chulett
Be careful with simple solutions like this, they will work fine for the most part, but once in a while generate an invalid date. For example, bump a leap-year Feb 29th by a year.

I haven't tried this myself, but you might try doing the Iconv/Oconv pair thing and adding 365 to the internal date...

-craig

Posted: Wed Aug 07, 2002 9:10 am
by DSGuru
Hi Santosh,

The problem of simple solution is 02/29/2000 + 1 = 02/29/2001 (There's no such date, just like one of the helper mentioned)

you have to split the date into 3 portion, yyyy, mm, dd
then use the yyyy to test for leap year by mod it by 4 and remainder is 0. If it's leap year then check the month to see if it's 02 (Feb), if it's Feb and the date is 29 then minus 1 for it to be 28 then you can add 1 to the year, else just add 1 to the year.


Take care and good luck.

Leon