× 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.



Hello Jörg,

Thank you very much for the info.
In the new development, I use COBOL+ESQL too..

Regards

Roman






Egger Jörg (KIRJ 412) <joerg.egger@xxxxxxxxxxxxxxxxx>
Sent by: cobol400-l-bounces@xxxxxxxxxxxx
18.01.2008 11:27
Please respond to
COBOL Programming on the iSeries/AS400 <cobol400-l@xxxxxxxxxxxx>


To
"COBOL Programming on the iSeries/AS400" <cobol400-l@xxxxxxxxxxxx>
cc

Subject
Re: [COBOL400-L] Obtaining current TIMESTAMP - the Solution






If you check embedded SQL you find better support.

EXEC SQL
SET timestamp-field to CURRENT TIMESATMP
END-EXEC.

Thanks and Regards

Jörg Egger (Beni)

CREDIT SUISSE
KIRJ 412
Uetlibergstrasse 231
8070 Zürich

E-mail: joerg.egger@xxxxxxxxxxxxxxxxx
Phone +41 44 334 39 32
Fax +41 44 334 58 55

-----Original Message-----
From: cobol400-l-bounces@xxxxxxxxxxxx
[mailto:cobol400-l-bounces@xxxxxxxxxxxx] On Behalf Of RMiklos@xxxxxx
Sent: 18 January 2008 10:49
To: COBOL Programming on the iSeries/AS400
Subject: Re: [COBOL400-L] Obtaining current TIMESTAMP - the Solution

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
--
This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing
list To post a message email: COBOL400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/cobol400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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

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.