BTW the SQL scalar function TIMESTAMP_FORMAT (introduced with release 6.1)
can convert a character representation of a timestamp (in almost any format)
into a real date:
... and it is even documented that:
"Leading zeroes can be specified for any component of the timestamp value
(for example., month, day, hour, minutes, seconds) that does not have the
maximum number of significant digits for the corresponding format element in
the format string" (SQL Reference)

The following examples will return the same timestamp i.e. '1964-07-01
05.07.03'
/Free
Exec SQL Set :MyTimestamp = Timestamp_Format('64/01/07 05.07.03',
'RR/MM/DD HH.MI.SS');
Exec SQL Set :MyTimeStamp = Timestamp_Format('64/1/7 5.7.3',
'RR/MM/DD HH.MI.SS');

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 Vern Hamberg
Gesendet: Saturday, 24. March 2012 14:52
An: RPG programming on the IBM i / System i
Betreff: Re: Date conversion from m/d/ccyy format

InFollowingThisThread,I'veHadTheCEE*Date/timeFunctionsInTheBackOfMyMind.(The
SpaceBarOnThisLaptopIsDying!ReplacementDueToArriveNextWeek.)

CEESECS converts a picture string into some number of seconds since
sometime. It lets you omit leading zeroes - here is an interesting bit
from the docs -

Each character in *picture_string* represents a character in
*input_timestamp*. If delimiters such as the slash (/) appear in the
picture string, leading zeros may be omitted. For example, these calls
assign the same value to the variable /secs/.

CALL CEESECS('88/06/03 15.35.03',
'YY/MM/DD HH.MI.SS', secs, fc);

CALL CEESECS('88/6/3 15.35.03' ,
'YY/MM/DD HH.MI.SS', secs, fc);

CALL CEESECS('88/6/3 3.35.03 PM',
'YY/MM/DD HH.MI.SS AP', secs, fc);

CALL CEESECS('88.155 3.35.03 pm',
'YY.DDD HH.MI.SS AP', secs, fc);



On 3/24/2012 12:22 AM, John Yeung wrote:
On Fri, Mar 23, 2012 at 6:53 PM, Barbara Morris<bmorris@xxxxxxxxxx>
wrote:
On 2012/3/23 11:28 AM, John Yeung wrote:
For the *USA format, %DATE handles single
digits for both month and day.
That's not a documented feature. RPG officially
requires that the month and day each have two
digits, with leading zeros if necessary.
That is what I expected, but I tried it out on the V5R2 machine at
work, and the leading zeros were not needed.

Chuck's message suggests maybe the language implementation was
tightened up to better match the docs in subsequent versions. In my
opinion, this is not a good direction. Working with dates is such a
ridiculously common thing to do, and so, so easy for the compiler to
handle this kind of thing, why force everyone to roll their own?
Sure, folks who know what they're doing will probably just put it in a
service program and always call it from there, but... it just seems
like such a waste. (And you *know* some folks will not implement
their routine correctly. How many incorrect home-brew leap-year
calculators are out there? Way too many to count.)

John

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.