|
David Gibbs (david.gibbs@silvon.com) wrote: >Ok, this ones pretty basic... So is the response. :-) >Anyone have a good routine to build a timestamp field? I presume you mean in OPM RPG? I've used the following very simple code successfully. The time stamp is built in the data structure TSTP. ITSTP DS I 1 2 CEN I 3 4 YR I 5 5 H1 I 6 7 MTH I 8 8 H2 I 9 10 DAY I 11 11 H3 I 12 13 HR I 14 14 D1 I 15 16 MIN I 17 17 D2 I 18 19 SEC I 20 20 D3 I 21 26 MSEC I DS I 1 140TOD I 1 2 HH I 3 4 MN I 5 6 SS I 7 8 DD I 9 10 MM I 11 12 CC I 13 14 YY C TIME TOD C MOVE CC CEN C MOVE YY YR C MOVE '-' H1 C MOVE MM MTH C MOVE '-' H2 C MOVE DD DAY C MOVE '-' H3 C MOVE HH HR C MOVE '.' D1 C MOVE MN MIN C MOVE '.' D2 C MOVE SS SEC C MOVE '.' D3 C MOVE *ZEROS MSEC There are a couple of points to remember. Firstly the layout of positions 7 - 14 of the TOD field is determined by the QDATFMT system value. On our AS/400's it's set to DMY; you probably have a different format and will have to adjust accordingly. If the code needs to be portable you can't assume any given setting of QDATFMT, so you would have to retrieve it and then juggle the date fields returned from the TIME op code. If someone has an example that does this neatly I'd be quite interested in seeing it myself - remember the returned format could be Julian if the machine is in the hands of a maniac. :-) Secondly you need to compile the program with CVTOPT(*DATETIME) in order for the program to be able to recognise the TIMESTAMP data type. HTH Dave Kahn - TCO, Tengiz, Kazakstan ========= e-mail: kahn@tengizchevroil.com (until September 30th) dkahn@cix.compulink.co.uk (from October 1st) +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to "MIDRANGE-L@midrange.com". | To unsubscribe from this list send email to MAJORDOMO@midrange.com | and specify 'unsubscribe MIDRANGE-L' in the body of your message. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.