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 seconds into date & time

0 Likes
3,584

Hi Friends,

please help me to convert seconds into date & time, if any FM available in SAP?

Cheers,

Thayalan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,956

If you want to convert some number of seconds into the number of days, hours, minutes and seconds:

REPORT ztest LINE-SIZE 250.

DATA: seconds TYPE i VALUE 180001,
      days    TYPE i,
      dur_ti  LIKE sy-uzeit.

days = seconds DIV 86400.      "Seconds per day
seconds = seconds MOD 86400.
dur_ti = seconds.

WRITE : /001 days, dur_ti.

It doesn't make sense to convert the number of days into years, months and days because both months and years can have different number of days.

Rob

5 REPLIES 5
Read only

Former Member
0 Likes
1,956

I guess you are trying to convert time stamp.

Try IB_CONVERT_FROM_TIMESTAMP .

Read only

Former Member
0 Likes
1,956

I am not sure how you can? You need some date and time plus seconds to calculate the resultant date and time.

If I give 3600 seconds as input and ask for the date and time, how can it be calculated without a reference date and time? I just know that it is 1 hour, but I cannot give it a date time stamp.

Can you please restate your requirement?

regards,

Srinivas

Read only

Former Member
0 Likes
1,957

If you want to convert some number of seconds into the number of days, hours, minutes and seconds:

REPORT ztest LINE-SIZE 250.

DATA: seconds TYPE i VALUE 180001,
      days    TYPE i,
      dur_ti  LIKE sy-uzeit.

days = seconds DIV 86400.      "Seconds per day
seconds = seconds MOD 86400.
dur_ti = seconds.

WRITE : /001 days, dur_ti.

It doesn't make sense to convert the number of days into years, months and days because both months and years can have different number of days.

Rob

Read only

0 Likes
1,956

Hi Rob,

It was helpful answer for me,But I've solved the problem by using calling some UNIX rountines.

Thanks.

Read only

0 Likes
1,956

can you share the UNIX routine here

Thanks in advance.

Regards

Raja