Page 1 of 1

Subtract Week From Date

Posted: Sat Jun 25, 2005 10:29 am
by shiva459
Hi All

I have a requirement where i need to subtract 7 days from the date.The source date has date format of yyyy-mm-dd.
For a sample date of 2003-01-10,the output should be 2003-01-03 and for 2003-01-03 the output should be 2002-12-27

I tried using Oconv and Iconv but could not get to the solution.Please help me to acheive the same.

Thanks in advance

Posted: Sat Jun 25, 2005 10:36 am
by chulett
You might want to post what you've tried so far. It's just a simple Iconv to get it into a Internal date, subtract 7 from that and then Oconv it back out in the format you want to see it - all doable in one 'line' provided you don't need to do any error checking.

Posted: Sat Jun 25, 2005 1:32 pm
by Sainath.Srinivasan
You need to make sure that the format is correct. Also you need to verify the possibility of null values and / or incorrect date values in that field.

Posted: Sun Jun 26, 2005 12:42 am
by shiva459
I am sorry ,I did try it and there was small syntax error which I was not able to locate.I found out that now and it works fine,
Oconv((Iconv(Arg1,"D-YMD")-7),"D-YMD").

Thanks for your help.