Diff between Timestamp



IBM's cross-platform compiler PL/I for MVS, VM & VSE, OS/390 and Enterprise PL/I for z/OS

Diff between Timestamp

Postby Shakthivel V » Tue Aug 10, 2010 2:35 pm

Hi. How to get the difference between two timestamp in PL/I??
Shakthivel V
 
Posts: 22
Joined: Thu Mar 04, 2010 12:12 am
Has thanked: 0 time
Been thanked: 0 time

Re: Diff between Timestamp

Postby NicC » Wed Aug 11, 2010 1:49 am

Are these DB2 timestamps?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3026
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Diff between Timestamp

Postby Shakthivel V » Wed Aug 11, 2010 2:30 pm

yes.. Its DB2 Timestamp only. but i need to check in my pli program .
Shakthivel V
 
Posts: 22
Joined: Thu Mar 04, 2010 12:12 am
Has thanked: 0 time
Been thanked: 0 time

Re: Diff between Timestamp

Postby NicC » Wed Aug 11, 2010 4:41 pm

I think you can use the DAYS builtin function - convert both, subtract and then another BIF (same section of the manual) to convert the result back to time. Something like

diff = days(ts1) - days(ts2)
ans = ????(diff)
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3026
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Diff between Timestamp

Postby prino » Wed Aug 11, 2010 8:29 pm

NicC wrote:I think you can use the DAYS builtin function - convert both, subtract and then another BIF (same section of the manual) to convert the result back to time. Something like

diff = days(ts1) - days(ts2)
ans = ????(diff)


Don't "think you can use", if you had RFTM, you would have known that the DAYS builtin is useless for DB2 timestamps, none of the PL/I builtin functions supports the "YYYYMMDDHHMISS999999" format of DB2 timestamps!

You need extended float (i.e. FLOAT DEC (33), or FLOAT DEC(34) for DFP)) to cater for the full range of self-calculated microseconds, unless you split it in date and time parts, in which case you still have to handle the micro-second part yourself!
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 617
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 28 times

Re: Diff between Timestamp

Postby NicC » Wed Aug 11, 2010 8:48 pm

Good catch - I only glanced at the manual. One can always drop off the microseconds unless it is so really important but that is the analyst's call.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3026
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times


Return to PL/I

 


  • Related topics
    Replies
    Views
    Last post