datetime difference

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
bhaskarjha
Participant
Posts: 67
Joined: Thu Apr 06, 2006 7:13 am

datetime difference

Post by bhaskarjha »

With source as oracle and target as oracle , i am not able to pass the date , its going NULL in the target,

ALSO with INPUT as 12/18/2001 10:10:44 PM and 12/18/2001 10:10:54 PM , how to get the difference in days or in minites.
Bhaskar Jha
sb_akarmarkar
Participant
Posts: 232
Joined: Fri Sep 30, 2005 4:52 am
Contact:

Post by sb_akarmarkar »

Hi,

From database itself you can get days difference by writing user defined query oracle source. Or using ICONV and OCONV with "MTH", You can get time difference in Datastage.


Thanks,
Anupam
sb_akarmarkar
Participant
Posts: 232
Joined: Fri Sep 30, 2005 4:52 am
Contact:

Post by sb_akarmarkar »

Use following to get time in min
Arg1 and Arg2 is time ex: "02:34 am"

Result=Oconv((Iconv(Arg1[1,8],"MTH") - Iconv(Arg2[1,8],"MTH")),"MTH")

Ans= (substrings(Result,1,2) * 60) + substrings(Result,4,2)


Thanks,
Anupam
bhaskarjha
Participant
Posts: 67
Joined: Thu Apr 06, 2006 7:13 am

Post by bhaskarjha »

Thanks Anupam, for the solution.
I am looking for the difference in dates , say 12/31/2002 6:00:00 PM and 12/31/2002 6:00:00 PM and 19/31/2002 6:30:00 AM where both r having datatype as timestamp and target is having datatype as NUMBER (here difference will be in MInutes)

Can u plz give the Solution for this.
Bhaskar Jha
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You need to right a custom routine for that. First Iconv the date part from both timestamps, check the difference. If the difference is <> 0 then multiply that with 24*60 to get the minutes diff. in the dates. then Iconv the time part and get the diff. and divide that by 60.
Add the two numbers and thats your difference between the two timestamps.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

This should help
viewtopic.php?t=85788
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Wow Ken, thats the solution right there. Thanks for pointing that out to us.
Cheers.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
sb_akarmarkar
Participant
Posts: 232
Joined: Fri Sep 30, 2005 4:52 am
Contact:

Post by sb_akarmarkar »

bhaskarjha wrote:Thanks Anupam, for the solution.
I am looking for the difference in dates , say 12/31/2002 6:00:00 PM and 12/31/2002 6:00:00 PM and 19/31/2002 6:30:00 AM where both r having datatype as timestamp and target is having datatype as NUMBER (here difference will be in MInutes)

Can u plz give the Solution for this.

Using this function you will get number of day , Convert it into minute

Iconv(Arg1[1,10],"D/MDY") - Iconv(Arg2[1,10],"D/MDY")

Thanks,
Anupam
akarmarkar@smart-bridge.co.in
Post Reply