× 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 Emily,

What you're asking for is relatively easy to do, if you substring the input field (your 13 char timestamp) into a separate date and time, and then put them back together to make a timestamp.

For example:

D Input s 13a inz('1071204122843')
D TS s Z
D D s D
D T s T

/free
D = %date( %subst(Input:1:7) : *CYMD0 );
T = %time( %subst(Input:8:6) : *HMS0 );
TS = D + T;

In this example, TS is the RPG timestamp field. So, in 3 lines of code, I've converted positions 1-7 into an RPG date, converted positions 8-13 into an RPG Time, and then combined them into a timestamp.

If you like, you can do it all in one expression, which may be a little more tricky to see what's going on, but eliminates the need for the extra date & time variables:

D Input s 13a inz('1071204122843')
D TS s Z

/free
TS = %date( %subst(Input:1:7) : *CYMD0 )
+ %time( %subst(Input:8:6) : *HMS0 );


Emily Smith wrote:
I'm receiving a date field from a customer that is 13 bytes long and
formatted like this CYYMMDDHHMMSS

I need to write this out to a timestamp field in a file. Can anyone
help me figure this out? I could try checking the value of the
century portion of the date, to determine whether or not it's from
this century or last, and then do a bunch of substringing and
concatenating to build a field in timestamp format, but I was hoping
there was a better way to accomplish this.

Thanks

Emily

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.