Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 2504
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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
This topic is locked: you cannot edit posts or make replies. 00D3003B - time outs in DB2 when invo... chavinash2004 DB2 2 Mon Oct 09, 2017 4:39 pm
No new posts VSAM RLS Wait time blayek JCL & VSAM 2 Mon Oct 02, 2017 9:05 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
No new posts Comparing 2 Files using Current time arunsoods SYNCSORT 9 Fri Sep 22, 2017 6:00 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us