Page 1 of 1

Difference Between Tow Date

Posted: Tue May 18, 2004 6:02 am
by arunverma
Can any body help me in DataStage Designer , How to get number of days between to date , currently I am using routine DateGenericDateDiff,
and here we have to give input date like 20040518 (yyyymmdd) , toget this format we have to first conver date into string format then substr for year, month and day and merge. Due to this resone my job is running very much slow .

Ex:- DateVal1 := 2004-05-18
DateVal2 := 2004-05-18


DateGenericDateDiff
(DateVal1[1,4]:DateVal1[6,2]:DateVal1[9,2],
DateVal1[1,4]:DateVal1[6,2]:DateVal1[9,2] )

Is it any routine available where we can pass two date directly jsut like
oracle ?

select (sysdate-to_date('2004-05-18','YYYY-MM-DD') )
from dual

Posted: Tue May 18, 2004 6:12 am
by nag0143
using Iconv(DateVal1)-Iconv(DateVal2) should give you number of days.


HTH
nag

Posted: Tue May 18, 2004 7:16 am
by chulett
To expand a little on what Nag said, converting dates to an internal format (Iconv) and then subtracting them will give you the difference in days. You really need to become friends with both Iconv and Oconv as they are staples of date handling in DataStage. A third function that works well with them is the Status function which, when used with the other functions in a routine, can be used to check the validity of dates when converting from one form to another.

Check your online help, or look at the source for the date handling routines in the 'sdk' category for some working examples.

Posted: Tue May 18, 2004 4:06 pm
by ray.wurlod
See the paper Date Conversion Demystified to learn about conversion of dates using the Iconv and Oconv functions.

Posted: Wed May 19, 2004 3:11 am
by arunverma
Thanks ,

I applied this logic , Now my job is working fine .


arun