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

date time difference

Former Member
0 Likes
715

Hi All ,

i have a requirement to calculate the difference between two corresponding date & time.

for eg: ( date2 & time2 ) - ( date1 & time1 )

the resultant field should give me time either in hrs or minutes.

i have used "SD_DATETIME_DIFFERENCE" it is working but it is giving the value as 0. if the time difference is less than 1 hr. but the requirement is to get the minutes also .

Thanks in Advance

Kishore Kumar Yerra.

6 REPLIES 6
Read only

Former Member
0 Likes
678

Hi,

try FM

DAYS_BETWEEN_TWO_DATES

FIMA_DAYS_BETWEEN_TWO_DATES

FIMA_DAYS_BETWEEN_TWO_DATES_2

and for time

HRVE_GET_TIME_BETWEEN_DATES

hope it helps..

Lokesh

Read only

Former Member
0 Likes
678

Hi Kishore,

YOu can directly use a int variable to hold the difference.

data: v_date_diff type i,

v_time_diff type i.

v_date_diff = date2 - date1.

v_time_diff = time2 - time1. " Gives difference in seconds

v_time_diff = v_time_diff / 60. " Gives difference in Minutes

Read only

Former Member
0 Likes
678

use the fm /SDF/CMO_DATETIME_DIFFERENCE

Read only

FredericGirod
Active Contributor
0 Likes
678

Hi,

you don't need any function to do that .

data : w_date type sy-datum value '20060101' ,
       w_hour type sy-uzeit value '080134' ,
       w_dat2 type sy-datum value '20060201' ,
       w_hou2 type sy-uzeit value '070554' .

w_date = w_dat2 - w_date.
if w_hour lt w_hou2.
  w_date = w_date - 1.
endif.
w_hour = w_hou2 - w_hour.

write : /1 w_date ,
           w_hour.

Rgd

Frédéric

Read only

Former Member
0 Likes
678

hi kishore ,

use this fm .

L_TO_TIME_DIFF.

I_START_DATE --start date

I_START_TIME 00:00:00

I_END_DATE ---enddate

I_END_TIME 00:00:00

I_TIME_UOM -


hrs/min/sec

pass the following parametes and get the difference in hrs or min or sec ,.

hope this helps u out .

regards,

vijay.

I_START_DATE 03/12/2006

I_START_TIME 18:00:00

I_END_DATE 03/12/2006

I_END_TIME 24:00:00

I_TIME_UOM MIN

Export parameters Value

E_TIME_DIFF 360.000

Message was edited by: Kan Vijay

Read only

Former Member
0 Likes
678

u can use:

data : time type sy-uzeit.

if time difference lt 1.

time = time1 - time2.

min = time+2(2).

Regards,

Bikash