×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




Hallo,

Thank you all very very much for your response an for your help !

I could find nothing about the TIMESTAMP-format in the IBM COBOL manuals
(ILE COBOL Reference and ILE COBOL Programmer's Guide)
They have only examples with DATEs and TIMEs there.

So, I introduced a paragraph which creates the DB/2-Timestamp as follows

DB2-TIMESTAMP.
* Create DB2-TimeStamp as YYYY-MM-DD-HH.MM.SS.CC0000
* Input parameters:
* ZW-DATE-X = YYYYMMDD
* ZW-TIME-X = HHMMSSCC
* as given from the Intrinsic Function CURRENT-DATE
STRING ZW-DATE-X(1:4) '-'
ZW-DATE-X(5:2) '-'
ZW-DATE-X(7:2) '-'
ZW-TIME-X(1:2) '.'
ZW-TIME-X(3:2) '.'
ZW-TIME-X(5:2) '.'
ZW-TIME-X(7:2) '0000'
DELIMITED BY SIZE INTO ZW-TIMESTAMP-X
END-STRING.

where the needed I/O-parameters are declared as

05 ZW-DATE-X PIC X(8).
05 ZW-TIME-X PIC X(8).
05 ZW-TIMESTAMP-X PIC X(26).


Now with other fields declared

05 ZW-DATE FORMAT DATE IS '@Y%m%d'.
05 ZW-TIME FORMAT TIME IS '%H%M%S@Sh'.
05 ZW-TIMESTAMP FORMAT TIMESTAMP.
05 ZW-TIMESTAMP-DB FORMAT TIMESTAMP.
05 ZW-CURRENT-DATE PIC X(21).
05 ZW-DURATION PIC 9(9).

I can create the current TIMESTAMP from current DATE and TIME

MOVE FUNCTION CURRENT-DATE TO ZW-CURRENT-DATE
MOVE ZW-CURRENT-DATE(1:8) TO ZW-DATE
MOVE ZW-CURRENT-DATE(9:8) TO ZW-TIME
* Create TimeStamp
MOVE ZW-DATE TO ZW-DATE-X
MOVE ZW-TIME TO ZW-TIME-X
PERFORM DB2-TIMESTAMP
MOVE ZW-TIMESTAMP-X TO ZW-TIMESTAMP

Now I can use the timestamp for date+time computation:
For example, if my computed ZW-TIMESTAMP = '2008-01-18-09.57.29.090000',
then this

MOVE FUNCTION SUBTRACT-DURATION (ZW-TIMESTAMP HOURS 2
MINUTES 5)
TO ZW-TIMESTAMP-DB

returns ZW-TIMESTAMP-DB = '2008-01-18-07.52.29.090000' and computing the
duration between the two Timestamps

COMPUTE ZW-DURATION = FUNCTION
FIND-DURATION (ZW-TIMESTAMP ZW-TIMESTAMP-DB MINUTES)

returns ZW-DURATION = 000000125 (Minutes).

So, thanks to your help, it works !


But, I wonder why IBM does nothing to improve a little bit their
COBOL-Compiler to handle better dates+times.
They provide 2 different date+time formats:
One for date+time returned from the intrinsic function CURRENT-DATE as a
21-Character-String,
e.g.'2008011809572909+0100'
and the other for timestamp as a 26-Character-String, e.g.:
'2008-01-18-09.57.29.090000'

That is very confusing and seems to have no sense !

The intrinsic function CURRENT-DATE, should have an optional parameter to
return the current timestamp, or it should return by default a
31-Character-String of this form
'2008-01-18-09.57.29.090000+0100'
from which the timestamp could be easy taken. Or they could deliver a new
intrinsic function named CURRENT-TIMESTAMP.


Regards

Roman
Mgr. Ing. Roman MIKLÓŠ
Prvá stavebná sporiteľňa a.s.
Bajkalská 30, P. O. Box 48
829 48 Bratislava 25
Tel.: +421/ 2 / 582 31 174
Fax: +421/ 2 / 582 31 109

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.