Plex 2E

 View Only
  • 1.  Ile-Rpg generator. Get Date from Timestamp

    Posted Jan 06, 2020 08:01 AM
    Edited by Gunnar Gunnarsson Jan 07, 2020 04:42 AM
    I need code to extract Date (and Time) from Timestamp in Server function (ile-rpg).  This looks promising:


    /FREE
    &(2:) = %date(&(1:):*ISO);
    &(3:) = %time(&(1:):*ISO);
    /END-FREE

    Here the parameters are from FIELDS; TimeStampISO, DateISO, TimeISO.

    But those fields are generated as Zoned numeric,  not as native ile-rpg Datetypes, so %Build in function are not possible.

    Any suggestion ?

     



  • 2.  RE: Ile-Rpg generator. Get Date from Timestamp
    Best Answer

    Posted Jan 07, 2020 01:13 AM
    Hi Gunnar,

    Try a move to a date field from Time stamp

    WRK.date of birth = JOB.*System time stamp

    works also for time field

    Kari


  • 3.  RE: Ile-Rpg generator. Get Date from Timestamp

    Posted Jan 07, 2020 10:20 AM
    I do not know about data types, but for timestamp to date we use:
         C     &(2:)         DIV       1000000000000 &(1:)​
    with Parm1 being DateISO, and Parm2 being TimeStampISO

    We do not appear to have any code for timestamp to time, but we do have the following for hours, minutes, and seconds.  It looks like these could be adapted, or you could use Time6 and convert that.
    Hours, Parm1 is TimestampISO, Parm 2 is Hours
          * Get Time From Timestamp
         C*     &(2:)         DIV       1000000       MYTIME            6 0
          * Get Hour From Time                            
         C*     MYTIME        DIV       10000         &(1:)
         C                   EVAL      &(1:) = %subdt(%timestamp(&(2:)):*HOURS)​


    Minutes: Parm1 is TimestampISO, Parm 2 is minutes
          * Get Time From Timestamp
         C*     &(2:)         DIV       1000000       MYTIME            6 0
          * Get Minute From Time                            
         C*     MYTIME        DIV       100           &(1:)
         C                   EVAL      &(1:) = %subdt(%timestamp(&(2:)):*MINUTES)​


    Seconds:  Parm1 is TimestampISO, Parm 2 is Seconds
          * Get Time From Timestamp
         C*     &(2:)         DIV       1000000       MYTIME            6 0
          * Get Second From Time                            
         C*                   Z-ADD     MYTIME        &(1:)
         C                   EVAL      &(1:) = %subdt(%timestamp(&(2:)):*SECONDS)​