×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
Date and Time could be declared with the specific format like
05 ZW-DATE FORMAT DATE IS '@Y%m%d'.
05 ZW-TIME FORMAT TIME IS '%H%M%S@Sh'.
but the Timestamp will be declared only like (without the given format)
05 ZW-TIMESTAMP FORMAT TIMESTAMP.
Now, when I have declared some other fields
05 ZW-AKTDAT PIC S9(8) COMP-3.
05 ZW-AKTZEIT PIC S9(8) COMP-3.
05 ZW-CURRENT-DATE PIC X(21).
05 ZW-CURRENT-DATE-RED REDEFINES ZW-CURRENT-DATE.
10 ZW-CUR-DATE PIC X(16).
10 FILLER PIC X(5).
05 ZW-TIME-DB FORMAT TIME IS '%H%M%S@Sh'.
05 ZW-DURATION PIC 9(9).
I can now obtain current date and time using the intrinsic function, e.g:
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
* Extract Date to Numerical Format yyyymmdd
COMPUTE ZW-AKTDAT =
FUNCTION EXTRACT-DATE-TIME (ZW-DATE '@Y%m%d')
* Extract Time to Numerical Format hhmmsscc
COMPUTE ZW-AKTZEIT =
FUNCTION EXTRACT-DATE-TIME (ZW-TIME '%H%M%S@Sh')
and I can as well ADD-, SUBSTARCT- or FIND-DURATION, e.g:
MOVE FUNCTION SUBTRACT-DURATION (ZW-TIME HOURS 1)
TO ZW-TIME-DB
COMPUTE ZW-DURATION = FUNCTION
FIND-DURATION (ZW-TIME ZW-TIME-DB MINUTES)
With DATE- and TIME-fields it works.
But how do I the same with TIMESTAMP ???
If I try
MOVE
FUNCTION CONVERT-DATE-TIME (ZW-CUR-DATE TIMESTAMP)
TO ZW-TIMESTAMP
I get an error:
Additional Message Information
Message ID . . . . . . : LNR7093 Severity . . . . . . . : 40
Message type . . . . . : Diagnostic
Date sent . . . . . . : 17/01/08 Time sent . . . . . . :
12:41:10
Message . . . . : The contents of date-time item does not match its
format.
Cause . . . . . : A date-time item's format is specified with a format
literal, either explicitly in a FORMAT clause or implicitly with a
LOCALE
phrase. The format literal consists of separators and specifiers.
The contents of the date-time item must match the separators within
the
format literal, and must be within a valid range of values for the
specifiers. The error was detected at statement 2509 of COBOL program
'OX122PSS' in program object 'OX122PSS' in library 'IBPDPGM'.
Recovery . . . : Correct the contents of the date-time item. In some
instances, the check that occurs to make sure the contents of the
date-time
item match the format literal can be prevented by using the *NORANGE
compiler option.
But I can not declare the Timestamp format, If I try to declare it, e.g
10 ZW-CUR-DATE FORMAT TIMESTAMP '%H%M%S@Sh%H%M%S@Sh'.
I get this Error from Compiler
Message . . . . : A FORMAT literal or SIZE phrase can not be
specified for a TIMESTAMP item. Literal or phrase ignored.
So, my questions are:
How is the COBOL TIMESTAMP defined?
How can I retrieve the CURRENT-TIMESTAMP or convert it from the result of
the function CURRENT-DATE ?
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 mailing list archive is Copyright 1997-2024 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.