Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Timestamp calculation.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
saubhik

New User


Joined: 21 Sep 2007
Posts: 35
Location: kolkata

PostPosted: Thu Jun 17, 2010 10:50 pm    Post subject: Timestamp calculation.
Reply with quote

Hi All,

My requirement is to calculate the difference between the two db2 table timestamp is 48 hours or not.

We have to fields

1. current timestamp. char(26)
2. created timestamp.char(26)
I need to find out the difference between these 2 fields is greater than 48 hours or 2 days or not.

Please let me know how to calculate this.
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Jun 17, 2010 10:53 pm    Post subject:
Reply with quote

Quote:
Please let me know how to calculate this.
In Assembler or PL/I?
Back to top
View user's profile Send private message
saubhik

New User


Joined: 21 Sep 2007
Posts: 35
Location: kolkata

PostPosted: Thu Jun 17, 2010 10:56 pm    Post subject:
Reply with quote

In PL1
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Thu Jun 17, 2010 11:16 pm    Post subject:
Reply with quote

Do you know the format?

If not, then you are sunk.

If so, then can you calculate the number of hours, minutes, or seconds each is, and then maybe subtract, and then maybe compare?
Back to top
View user's profile Send private message
saubhik

New User


Joined: 21 Sep 2007
Posts: 35
Location: kolkata

PostPosted: Thu Jun 17, 2010 11:20 pm    Post subject:
Reply with quote

I know the format of timestamp.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jun 17, 2010 11:22 pm    Post subject:
Reply with quote

since you are talking about 2 days,
simply extract the date portion,
populating a field that will work with the DAYS intrinsic function, see the example at bottom of page,

then add 2 days. reformat to your timestamp format and compare.

a wander thru the PL1 reference manual is all it takes,
unless of course all you want is someone to provide the code for you.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Thu Jun 17, 2010 11:24 pm    Post subject:
Reply with quote

methinks we need more resolution - 48 hours is really the requirement
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jun 17, 2010 11:27 pm    Post subject:
Reply with quote

Phrzby Phil wrote:
methinks we need more resolution - 48 hours is really the requirement


good chance. if so, he only needs to research the manual a little more.
Back to top
View user's profile Send private message
saubhik

New User


Joined: 21 Sep 2007
Posts: 35
Location: kolkata

PostPosted: Thu Jun 17, 2010 11:27 pm    Post subject:
Reply with quote

yes.48 hours calculation is actual requirement.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Thu Jun 17, 2010 11:28 pm    Post subject:
Reply with quote

We look forward to your solution, based on ample suggestions above.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jun 18, 2010 1:17 am    Post subject:
Reply with quote

Phrzby Phil wrote:
methinks we need more resolution - 48 hours is really the requirement


good one, had me going for a few minutes.

as in what is the difference between 48 hrs and 2 days?
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri Jun 18, 2010 1:25 am    Post subject:
Reply with quote

Quote:
as in what is the difference between 48 hrs and 2 days?

yyyymm03235900 - yyyymm01000100 = 2 days or almost 72 hours...
yyyymm03000100 - yyyymm01235900 = 2 days or just over 24 hours...
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jun 18, 2010 1:29 am    Post subject:
Reply with quote

I should not have smoked that thing!
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri Jun 18, 2010 1:38 am    Post subject:
Reply with quote

dbzTHEdinosauer wrote:
I should not have smoked that thing!
Not so, it sometimes helps...grin....
FWIW, a quick subtraction of just the days to determine if the difference is equal to two before the more involved hour calculation might save significant time if the difference is usually less than one ore greater than three.
Back to top
View user's profile Send private message
saubhik

New User


Joined: 21 Sep 2007
Posts: 35
Location: kolkata

PostPosted: Fri Jun 18, 2010 10:56 am    Post subject: Reply to: Timestamp calculation.
Reply with quote

Solution is geiven below.Let me know if it is correct or not.

hours_difference = (days difference)*24 + hours difference + (minutes difference) / 60
=[days (current tmstmp) - days (last_timestamp))] *24 +
[Hour(current tmstmp) - Hour(last_timestamp)] +
[Minute(current tmsmp) - Minute(last_timestamp)]/60
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Fri Jun 18, 2010 5:17 pm    Post subject:
Reply with quote

We don't need to let you know - just test it on an appropriate set of values.

Some will be exactly 48 hours, some a second longer, some shorter, etc. etc. etc.

Even test with the timestamps in the wrong order - do you test for this and generate an error message?

Designing test data is part of a programmer's responsibility.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Fri Jun 18, 2010 5:18 pm    Post subject:
Reply with quote

Dick -

Don't worry about it. You get up 6-7 hours before I do, so mistakes will happen.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting EBCDIC to Unicode (TimeStamp) muralikrishnan_new COBOL Programming 2 Mon Jul 25, 2016 10:42 pm
No new posts Convert Timestamp Value mrdinesh DFSORT/ICETOOL 7 Thu May 05, 2016 6:01 pm
No new posts MSU calculation for DB2 (to decide be... SRICOBSAS DB2 4 Wed Mar 23, 2016 6:07 pm
No new posts Comparing timestamp in Synscort l.nethaji SYNCSORT 13 Wed Jan 20, 2016 4:47 pm
No new posts pass numeric value of length 14 to ti... Ralph Zbrog Java & MQSeries 4 Fri Jan 15, 2016 3:20 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us