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




On 17/01/2008, at 11:21 PM, RMiklos@xxxxxx wrote:

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.

I presume you are basing your code on the information in the ILE COBOL Reference which states:

CONVERT-DATE-TIME

argument-2
Specifies the format of the return value and must be one of the following keywords:
o DATE
o TIME
o TIMESTAMP

The documentation is wrong. Argument-2 actually specifies the format of Argument-1. This makes sense when you consider that CONVERT-DATE- TIME returns a date-time data type so the compiler already KNOWS the format of the return value because it's been defined when the variable was declared in the code. What it doesn't know is the layout of the character or numeric data type that REPRESENTS a date or time.

Changing your code to:
FUNCTION CONVERT-DATE-TIME (ZW-CUR-DATE DATE "@Y%m%d") TO ZW-TIMESTAMP
will solve your immediate problem, but it will only populate the date portion of the timestamp variable.

Note that even if Argument-1 is a date-time data type you still have to specify the correct value for Argument-2 to satisfy the syntax requirements even though the compiler KNOWS the format of Argument-1.

However, while that knowledge helps with converting character/numeric dates/times to real dates/times/timestamps it does not help with converting the result of CURRENT-DATE to a real date/time/timestamp. I could not find any way to get CONVERT-DATE-TIME to accept a picture string describing CURRENT-DATE (or at least the parts up to the time- zone) when Argument-2 was DATE, TIME, or TIMESTAMP. All attempts resulted in compiler errors.

Seems rather stupid to me for a language to provide a CONVERT-DATE- TIME function that cannot/does not support converting the CURRENT- DATE picture into something usable by the XXX-DURATION functions without requiring the programmer to perform data manipulation on said CURRENT-DATE result to fabricate a character/numeric date/time. Perhaps I'm missing something?

Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------




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.