Subtract Week From Date

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
shiva459
Premium Member
Premium Member
Posts: 100
Joined: Wed Jun 11, 2003 1:49 am
Location: Bangalore

Subtract Week From Date

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post 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.
shiva459
Premium Member
Premium Member
Posts: 100
Joined: Wed Jun 11, 2003 1:49 am
Location: Bangalore

Post 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.
Post Reply