Diff between Timestamp

IBM's cross-platform compiler PL/I for MVS, VM & VSE, OS/390 and Enterprise PL/I for z/OS
Shakthivel V
Posts: 22
Joined: Thu Mar 04, 2010 12:12 am
Skillset: DB2 , COBOL , JCL , PL1 , IMS , VSAM
Referer: google

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??

NicC
Global moderator
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
Referer: Google
Location: Pushing up the daisies (almost)

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

Shakthivel V
Posts: 22
Joined: Thu Mar 04, 2010 12:12 am
Skillset: DB2 , COBOL , JCL , PL1 , IMS , VSAM
Referer: google

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 .

NicC
Global moderator
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
Referer: Google
Location: Pushing up the daisies (almost)

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

User avatar
prino
Posts: 641
Joined: Wed Mar 11, 2009 12:22 am
Skillset: PL/I - CICS - DB2 - IDMS - REXX - JCL, most in excess of three decades
Referer: Google
Location: Vilnius, Lithuania
Contact:

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

NicC
Global moderator
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
Referer: Google
Location: Pushing up the daisies (almost)

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


  • Similar Topics
    Replies
    Views
    Last post