Skip to Content
avatar image
Former Member

Convert numeric data to timestamp

i want two variables with data type timestamp and numc3 . the content of the first variable is 12:30:00. and the content of the second variable is 022. It is basically in minutes. when i add up the two it gives the output as 12:30:22. which is wrong . i want to convert this numeric data to timestamp. is there any function module to do that. can any one help me ?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Jul 13, 2009 at 05:33 AM

    Hi,

    Test the bellow Sample Code it will solve out your problem,

    DATA: time LIKE sy-uzeit,
          min TYPE i,
          sec TYPE i.
    
    time = sy-uzeit.
    min = 50.       " Total Min
    sec = 50 * 60.  " Convert Min to Sec
    
    ADD: sec TO time.
    WRITE: time.

    Best Regards,

    Faisal

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 13, 2009 at 05:36 AM

    Hi Kallol,

    Multiply numc3 with 60 (convert min to sec) before adding to timestamp.

    Hope this helps!

    Regards,

    Saumya

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 13, 2009 at 05:42 AM

    convert ur minutes to TIME format

    e.g

    convert minutes to secs

        seconds = 22 * 60.
    

    Now convert to time format

          add_time+0(2) = seconds / 3600. "Hours
          seconds = seconds mod 3600.
          add_time+2(2) = seconds / 60.   "Minutes
          seconds = seconds mod 60.
          add_time+4(2) = seconds.         "Seconds
    

    now use FM CONV_UTIL_ADD_DATE_AND_TIME to add time to timestamp

          CALL FUNCTION 'CONV_UTIL_ADD_DATE_AND_TIME'
               EXPORTING
                    in_timestamp  = cur_tm_stmp
    *                add_days      = days
                    add_time      = add_time
               IMPORTING
                    out_timestamp = cur_tm_stmp.
    

    Add comment
    10|10000 characters needed characters exceeded