Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a COBOL utility that returns date/time fields? 3

Status
Not open for further replies.

sgeller

Programmer
Apr 2, 2004
3
US
Can anyone tell me if there's a utility that will return the current date/time? (eg. 2004-02-04-14.57.38). I looked at "ACCEPT fieldname FROM DATE", but that doesn't get more accurate than the day (ie. No hours, minutes, and seconds).
 
k5tm:

Thank you, but won't that only return the hours/minutes/seconds? I'm looking for something that will return the date AND time in one field.
 
Don't you have the CURRENT-DATE intrinsic function ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Thanks, PHV. This is what I was looking for.
 
Hi,

when you use ACCEPT DATE and ACCEPT TIME there is a chance that they don't fit with the moment you take it, for example when the program does this on the moment when the date is changing.

Suppose the program is taking time and date on 4 april 2004 23:59:59. When you first take the date and after that the time, it can happen that you get:

date: 040404
time: 00000001

or the other way around:

time: 23595999
date: 040405

In both cases time and date are inconsistent with the moment you got it. The difference is almost a complete day. If you take the date first and after that the time, you should check if the date is changed. If it is, you should take the time again.

If the FUNCTION CURRENT-DATE is available, you don't have this potential trouble, so it is better to use this function.

Regards,

Crox
 
Not sure of the the portability, but RM/Cobol provides/allows

Code:
ACCEPT date-field FROM DATE-AND-TIME

that guarantees a consistent timestamp. This returns the date/time in YYYYMMDDHHMMSSHH format. I guess this is essentially the equivalent of the CURRENT-DATE INTRINSIC function. RM/Cobol does not provide the intrinsic functions (or at least I haven't seen them yet).

"Code what you mean,
and mean what you code!
But by all means post your code!"

Razalas
 
Hi Crox & Razalas!

That was a very valuable post.
Just wanted to thank you ppl for that.

Thanks,
TB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top