|
> Is there an easy way to extract the date > and time from a timestamp? I can't seem to find one. There is only one: You have to use data structures for that. Something like: DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords D DS D myTimeS Z INZ(*LOVAL) D myDate 1 10 D DATFMT(*ISO) D myTime 12 19 T TIMFMT(*ISO) * Do not forget to INZ if necessary C*L0N01Factor1+++++++Opcode(E)+Extended-factor2| * C eval myTimeS = TSfromOuterSpace C ADDDUR 2:*DAYS myDate * etc... Btw: if using V4 i would suggest to use the fanatstic and powrful sub procedures for those operations often needed (especially date/time/timestamp ones), i.e. creating a server pgm or at least a "static link library". * Prototypes D exDate PR D DATFMT(*ISO) D timeSt Z CONST * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * exDate ( <timestamp> ) date * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * exDate extracts a Date from a timestamp * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * return value: the requested date * global vars : __none__ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * P exDate B EXPORT D exDate PI D DATFMT(*ISO) D TimeSt Z CONST * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - D myTimeStamp Z INZ(*LOVAL) D myDate 1 10 D DATFMT(*ISO) D myTime 12 19 T TIMFMT(*ISO) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - C eval myTimeStamp = TimeSt C RETURN myDate P exDate E * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * sub procedure for time analogous ... * especially for date/time operations... really useful e.g. * isLeapYear ( <date>) logical returns *ON if leapYear otherwise *OFF * year ( <date> ) 4P0 extracts year of a date * useful for "IF year(fromDate) <> year(toDate)", etc. * timestamp( <date> : <time> : <MS> ) cats those data to a timestamp * with <time> <MS> as options(*NOPASS) .. * etc...etc... * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * This is the RPG/400 Discussion Mailing List! To submit a new * * message, send your mail to "RPG400-L@midrange.com". To unsubscribe * * from this list send email to MAJORDOMO@midrange.com and specify * * 'unsubscribe RPG400-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-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.