View previous topic :: View next topic
|
Author |
Message |
Ramsee
New User
Joined: 06 Jan 2011 Posts: 53 Location: Chennai
|
|
|
|
Hi All,
Warm greetings!!
I need a help to find the time difference between the two timestamp.
INPUT:
Code: |
START TIME END TIME
05:10:00 07:20:00
05:15:00 05:30:00
06:59:00 07:10:00
05:50:00 06:55:00
OUTPUT:
START TIME END TIME TOTAL TIME
05:10:00 07:20:00 02:10:00
05:15:00 05:30:00 00:15:00
06:59:00 07:10:00 00:11:00
05:50:00 06:55:00 01:05:00
23:15:00 01:00:00 00:45:00
|
I tried a lot using CEESECS/CEEDATM for time difference calucation but not able get result as my compiler says.
Code: |
* Statistics for COBOL program CBLSECS:
* Source records = 98
* Data Division statements = 25
* Procedure Division statements = 19
End of compilation 1, program CBLSECS, highest severity 12.
Return code 12
|
Please guide me to solve this issue. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
How about showing the code? For all we know the 12 is nothing to do with your coding of the 2 functions that you mention.
Are you catering for events running past midnight, eg start 23:30 end 00:15? All your examples show start time less than end time. |
|
Back to top |
|
|
Ramsee
New User
Joined: 06 Jan 2011 Posts: 53 Location: Chennai
|
|
|
|
Hi Nic,
we run the jobs past midnight as well,
Code: |
START TIME END TIME TOTAL TIME
23:15:00 01:00:00 00:45:00
|
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Code: |
START TIME END TIME TOTAL TIME
23:15:00 01:00:00 00:45:00 |
why not review Your way of doing things
meditate a bit ... meditate |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Still not shown the code, so no way at all to guess what is wrong, other than guessing, which is pretty pointless.
Without the date as well, if you have a job running from 23:59 to 00:01 the day after the following day, you'll report two minutes instead of 24 hours and two minutes. So look out if you have things in your list which execute for more than 24 hours :-) |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Review the LE (Language Environment) Callable Service routine "CEESECS", which converts a given Date/Timestamp to Lilian Seconds. If you call it twice, with the starting and ending Date/Timestamp, subtract the starting Lilian result from the ending Lilian result and you'll have the difference in seconds. You can then convert these seconds to your desired "Time" format manually or use "CEEDATM". This method doesn't care if you started just before Midnight and ended after Midnight.
Search the MAINFRAME COBOL forum for CEESECS. You'll get many hits....
HTH.... |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
enrico-sorichetti wrote: |
Code: |
START TIME END TIME TOTAL TIME
23:15:00 01:00:00 00:45:00 |
why not review Your way of doing things
meditate a bit ... meditate |
It's a special end-of-day time discount, :-)
Ramsee, that particular example in your output doesn't appear in your input. So you missed it. not Nic.
Have a look at your compile options in the compiler listing. Do you have NOFLAG or FLAG(U)? |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Ramsee wrote: |
I tried a lot using CEESECS/CEEDATM for time difference calucation but not able get result as my compiler says.
Code: |
* Statistics for COBOL program CBLSECS:
* Source records = 98
* Data Division statements = 25
* Procedure Division statements = 19
End of compilation 1, program CBLSECS, highest severity 12.
Return code 12
|
|
You have compilation errors, that's all.
There are error messages right above these lines. What are they ?
For time arithmetics, you don't really need to use LE services:
If END time is on next day, add 24 to HOURS,
Compute the number of seconds: (((HOURS * 60) + MINS) * 60) + SECS for both END and START times,
Subtract the 2 numbers,
Recalculate the duration from seconds into time.
For example: 23:15:00 gives 83700 seconds,
01:00:00 (on next day so 25:00:00) gives 90000
The difference is 90000 - 83700 = 6300 seconds
Divide once by 60, gives 105 minutes with a remainder of 00 seconds.
Divide once more by 60, gives 1 hour with a remainder of 45 minutes.
So 01:00:00 - 23:15:00 gives 01:45:00 (and not 00:45:00) |
|
Back to top |
|
|
Ramsee
New User
Joined: 06 Jan 2011 Posts: 53 Location: Chennai
|
|
|
|
Hi All,
I am sorry for the late reply and not giving a full information on the topic.
The compiler issue was due to some parameter setup(In house) in my Compile JCL which is rectified now, and i am able to use the CEESECS/CEEDATM to calculate the time difference.
I thanks Mr.NIC ,Mr. Enrico, Mr.Bill O'Boyle,Mr. Bill Woodger,Mr.Marso and everyone for your time and help. |
|
Back to top |
|
|
|