View previous topic :: View next topic
|
Author |
Message |
poshabrar
New User
Joined: 10 Jul 2006 Posts: 23
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
...assuming both times are in the same day, of course. |
|
Back to top |
|
|
poshabrar
New User
Joined: 10 Jul 2006 Posts: 23
|
|
|
|
Thanks a lot Tary... Didn't even think that this would be so easy.... This simple if comparision works fine as I needed.
|
|
Back to top |
|
|
|