Thursday, October 18, 2007

Sample ABAP Program to Calculate difference between date/times in hours

DATA: l_start TYPE t,
l_end TYPE t,
l_startdate TYPE d,
l_enddate TYPE d,
l_hours TYPE p DECIMALS 2.

l_start = p_starttime.
l_end = p_endtime.
l_startdate = p_startdate.
l_enddate = p_enddate.

l_hours = ( ( l_enddate - l_startdate ) * 24
+ ( l_end - l_start ) / 3600 ).

1 comment:

Sachin said...

its a good programm.

but it fails when we give dates from two months.

ex: 15 feb 2010 to 21 mar 2010..
it will not take months in consideration..........

rest is good..