ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to get Time Stamp value in RPG3

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get Time Stamp value in RPG3

    Hi All,

    Please tell me how to get time stamp value in RPG3.
    Time stamp format should be in, yyyy-mm-dd.hh.mm.ss.mmmmmm.

    I have tried with TIME opcode to get time stamp value, but not getting micro seconds.

    Please help me.

    Thanks,
    Vishal.

  • #2
    Re: How to get Time Stamp value in RPG3

    Hello Vishal
    RPGIII (or RPG/400) does not support timestamp data types natively.

    TIME only returns a numeric timestamp. u can declare it 6,12,14 with decimal field

    Code:
    C                     TIME           TTIME  140          
    C           TTIME     DSPLY                              
    C                     SETON                         LR
    output will be:
    Code:
    [COLOR="DarkRed"]16192808102009[/COLOR]
    for ur knowledge i would like to tell you...

    A real timestamp field is 10 Byte long. In the first 4 Bytes the date is stored in a binary value (representing the number of days since x - scaliger no). In the next 3 Bytes the time is stored as follows: In the 1 Byte the hour is stored as binary value. The 2 Byte contains the minute as binary value and the 3 Byte contains the binary second. The microseconds are stored in the last 3 Bytes as packed numeric


    I think moving the time value in numeric field will resolve your problem.

    Let me know if u need more...


    Regards
    Young people knows how to run fast but old people knows the way..

    Comment


    • #3
      Re: How to get Time Stamp value in RPG3

      You could always use CVTRPGSRC, and then use the actual %timestamp bif.
      Michael Catalani
      IS Director, eCommerce & Web Development
      Acceptance Insurance Corporation
      www.AcceptanceInsurance.com
      www.ProvatoSys.com

      Comment


      • #4
        Re: How to get Time Stamp value in RPG3

        An other way is to use embedded SQL and return the timestamp as a 26A character value:

        PHP Code:
        C/EXEC SQL
        C
        +  SET :MYTSCHAR CHAR(CURRENT_TIMESTAMP)
        C/END-EXEC 
        In either way I'd suggest to move from RPGIII to RPGIV

        Birgitta

        Comment


        • #5
          Re: How to get Time Stamp value in RPG3

          You are right Birgitta!

          RPGIV has given you wonderful bif U can use them.

          i think his code will be written in RPGIII so he is keen to how to use timestamp in RPGIII.Just a wild guess...


          Regards
          Young people knows how to run fast but old people knows the way..

          Comment


          • #6
            Re: How to get Time Stamp value in RPG3

            Hi Pramendra,

            Thanks for reply.
            I have Move Time value to numeric field 14, 0 length.
            But RPG3, getting TIME opcode value in HHMMSSMMDDYYYY. Please let me know how to get micro seconds in RPG3.
            I need Time stamp format should be in, yyyy-mm-dd.hh.mm.ss.mmmmmm.

            Please help me.

            Thanks,
            Vishal.

            Comment


            • #7
              Re: How to get Time Stamp value in RPG3

              Hey Vishal!!!

              Pawan has asked the same question for answer please navigate to this page...

              http://www.code400.com/forum/showthr...ed=1#post44373


              Let me know wheter it helps.


              Regards
              pramendra pandeya
              Young people knows how to run fast but old people knows the way..

              Comment

              Working...
              X