Date Addition

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
bmnaidu
Charter Member
Charter Member
Posts: 16
Joined: Wed Jun 07, 2006 5:49 am

Date Addition

Post by bmnaidu »

How do we add a specific number of months to a date?
Similarly Days and Years.

Please help me.

Thanks in advance.
Thanks and Regards
NAIDU BUDDHA
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

In order to do anything with dates you will need to convert them from display to internal format; the most common way is to use the ICONV() function with the appropriate Date conversion [see the manual under "conversions" for details]. When you do have that integer date you can perform simple math and, once finished, can convert that back into a display date.
Another way is that you can use ICONV() to get the year, month and day numbers for a date as well. Then add the months (check for going into the next year) and use OCONV() to put these numbers back into a display date.
bmnaidu
Charter Member
Charter Member
Posts: 16
Joined: Wed Jun 07, 2006 5:49 am

Post by bmnaidu »

Thanks for info ArndW. I'll try. But I wonder if there is no function for manipulating dates. Is that are we missing any function or there is no function or API to handle such things.
Thanks and Regards
NAIDU BUDDHA
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I wrote a routine once to add days, hours, mins, seconds, upto milliseconds. Click here and check out the very last post.
As for adding months, its really depends upon your own requirements. Adding a month could mean adding either 30 days or 31 days or 28 days for Feb, OR it could mean just incrementing the month counter by 1. So it really depends.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
clshore
Charter Member
Charter Member
Posts: 115
Joined: Tue Oct 21, 2003 11:45 am

Post by clshore »

As has been discussed before, if you are doing date-month math, you need to define what happens in cases like this:

Jan 31, 2006 + 1 month = ???

Is it Feb 28, 2006?

What about:

Feb 28, 2006 - 1 month = ???

Is it Jan 28, 2006, or Jan 31, 2006?

Carter
bmnaidu
Charter Member
Charter Member
Posts: 16
Joined: Wed Jun 07, 2006 5:49 am

Post by bmnaidu »

Thanks for the suggestions. Can you please help me how to call that routine?
Thanks and Regards
NAIDU BUDDHA
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

What routine are you referring to. If its mine then its all there in the description.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply