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



Hi,

As others already pointed out, RPG can only convert the following character
representation 'YYYY-MM-DD-HH.MM.SS.MSMSMS' into a real timestamp.
But if you are already on release V5R4, you can use the scalar function
TIMESTAMP_ISO() and embedded SQL to convert the ANSI-Format ('YYYY-MM-DD
HH:MM:SS') into a real timestamp.

Exec SQL Set :MyRPGTS = TimeStamp_ISO('2007-10-30 07:30:00');
Exec SQL Set :MyRPGTS = TimeStamp_ISO(:MyCharTS);

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von Booth Martin
Gesendet: Monday, October 29, 2007 22:34
An: RPG programming on the AS400 / iSeries
Betreff: Re: %timestamp('2007-06-12 06:00:00') - what is wrong with it?


Two things:
First, yes, I hard coded it after having spent a while trying to match
up the manual to what was actually happening. I wanted to be sure that
I was doing exactly what I thought I was doing.
Second, these data are coming in from an XML document and I have no
control over what we get.

Scott Klement wrote:
hi Booth,


D wTimeStampEnd s z
C eval wTimeStampEnd =
C %timestamp('2007-06-12 06:00:00')


As 3500 replies have no doubt already told you, your syntax for the
timestamp literal isn't quite right. You need a dash between the date
and time, you need to use dots instead of colons, and you need to add
the microseconds.

C eval wTimeStampEnd =
C %timestamp('2007-06-12-06.00.00.000000')

The weird thing about this code is that you've created a hard-coded
character field, and you're running it through the %timestamp() BIF
(which is basically an IBM provided subprocedure) to convert it to a
timestamp field.

It'd be simpler (both for you, and for the computer) if you hard-code
it
as a timestamp literal instead of as a character string:

C eval wTimeStampEnd =
C z'2007-06-12-06.00.00.000000';

If you're getting your input from VARIABLES rather than hard-coding it
as a literal (which isn't what the example in your e-mail stated, but
perhaps you simplified the code for our sake) it might be easier to do
this instead:

D MyDate s 10a inz('2007-06-12')
D MyTime s 8a inz('06:00:00')
D wTimeStampEnd s z

C eval wTimeStampEnd = %date( MyDate: *ISO)
C + %time( MyTime: *HMS)

Doing it this way (adding a date to a time) eliminates the need to
hard-code the microseconds, and eliminates the need to muck around with
changing colons into dots, etc.

It all depends on what you're REALLY trying to do... :)



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.