Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Convert numeric data to timestamp

Former Member
0 Likes
1,227

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 ?

4 REPLIES 4
Read only

faisalatsap
Active Contributor
0 Likes
999

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

Read only

0 Likes
999

it has solved my problem . thanks

Read only

saumya_govil
Active Contributor
0 Likes
999

Hi Kallol,

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

Hope this helps!

Regards,

Saumya

Read only

Former Member
0 Likes
999

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.