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
 

 

Time comparision in COBOL......

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
poshabrar

New User


Joined: 10 Jul 2006
Posts: 23

PostPosted: Sun Nov 23, 2008 5:47 pm    Post subject: Time comparision in COBOL......
Reply with quote

I have two(A1,A2) varibles which hold HH:MM:SS data. I want to compare these variables IF(A1>A2)...

How to do this with minimal coding.

I already implemented the logic of moving HH:MM:SS into another variable and compare it as an integer HHMMSS.

Please suggest me if this can be done in any other way.
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sun Nov 23, 2008 9:13 pm    Post subject: Re: Time comparision in COBOL......
Reply with quote

If one of the HHMMSS occurred on a different day and greater than one day apart, this will be impossible to determine.

Do you have the associated date with these HHMMSS values?

At the very least, you need to convert them to seconds and then compare.

What if you had an HHMMSS of 105745 and another of 110310? Simple subtraction will not give you the answer without first converting or an HHMMSS of 235803 and 000724 (next day)?

Take a look at the LE Callable Service routine "CEESECS", which (amongst others) requires a date/time parm and will convert and return each of these to seconds.

As another idea (but also requires the associated date), use FUNCTION INTEGER-OF-DATE (or INTEGER-OF-DAY if date-format is julian) to calculate the lilian-days of each date. Then multiply this result by 86400 (number of seconds in a day), followed by converting the HHMMSS to seconds (HH * 3600, MM * 60 and SS as-is). Add these calculated seconds to each seconds-in-a-day result and then compare.

HTH....

Bill
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Sun Nov 23, 2008 9:24 pm    Post subject:
Reply with quote

I'd code it as follows:
Code:
 01  a1  pic  x(8).
*             hh:mm:ss
 01  a2  pic  x(8).
*             hh:mm:ss
     if a1 > a2
         display 'a1 > a2'
     else
         if a1 < a2
             display 'a1 < a2'
         else
             display 'a1 = a2'
         end-if
     end-if
     .
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Sun Nov 23, 2008 9:25 pm    Post subject:
Reply with quote

...assuming both times are in the same day, of course.
Back to top
View user's profile Send private message
poshabrar

New User


Joined: 10 Jul 2006
Posts: 23

PostPosted: Mon Nov 24, 2008 9:32 pm    Post subject: Reply to: Time comparision in COBOL......
Reply with quote

Thanks a lot Tary... Didn't even think that this would be so easy.... This simple if comparision works fine as I needed.



icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif
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 -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm


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