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

Calculating the time.

Former Member
0 Likes
493

Hi Experts,

when i enter starting date, starting time and ending date, ending time. I need to get the total duration in hours.

Is there any function module to resolve these issue or please provide me the logic.

Thanks and regards.

vijay

Hi Experts,

when i enter starting date, starting time and ending date, ending time. I need to get the total duration in hours.

Is there any function module to resolve these issue or please provide me the logic.

Thanks and regards.

vijay

2 REPLIES 2
Read only

naimesh_patel
Active Contributor
0 Likes
462

Hello,

Use FM : DELTA_TIME_DAY_HOUR

Pass:

T1 - start time

T2 end time

D1 start date

D2 start time

It give you the minutes. Devide it by 60 so, you get the hours.

regards,

Naimesh

Read only

Former Member
0 Likes
462

you can use

SD_DATETIME_DIFFERENCE

data : date1 type sy-datum,
       date2 type sy-datum,
       time1 type sy-uzeit,
       time2 type sy-uzeit,
       v_datediff type p,
       v_timediff type p.

       date1 = '20060101'.
       date2 = sy-datum.
       time1 = '010101'.
       time2 = sy-uzeit.
CALL FUNCTION 'SD_DATETIME_DIFFERENCE'
  EXPORTING
    DATE1                  = DATE1
    TIME1                  = TIME1
    DATE2                  = DATE2
    TIME2                  = TIME2
 IMPORTING
   DATEDIFF               = v_DATEDIFF
   TIMEDIFF               = v_TIMEDIFF
*   EARLIEST               = EARLIEST
 EXCEPTIONS
   INVALID_DATETIME       = 1
   OTHERS                 = 2
          .

IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

regards

srikanth

added program

Message was edited by: Srikanth Kidambi