Difference Between Tow 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
arunverma
Participant
Posts: 90
Joined: Tue Apr 20, 2004 8:20 am
Location: MUMBAI
Contact:

Difference Between Tow Date

Post 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
Arun Verma
nag0143
Premium Member
Premium Member
Posts: 159
Joined: Fri Nov 14, 2003 1:05 am

Post by nag0143 »

using Iconv(DateVal1)-Iconv(DateVal2) should give you number of days.


HTH
nag
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

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

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

See the paper Date Conversion Demystified to learn about conversion of dates using the Iconv and Oconv functions.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
arunverma
Participant
Posts: 90
Joined: Tue Apr 20, 2004 8:20 am
Location: MUMBAI
Contact:

Post by arunverma »

Thanks ,

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


arun
Arun Verma
Post Reply