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

Function Module to get the difference between two times.

Former Member
0 Likes
3,469

Hi All,

I want to know if there is any function module that gives me the difference between two specified times.

For Ex: Time 1: 12/01/2007 00:01 A.M

Time 2: Time 1 - 180 Seconds. This changes the time, also may even change the Date. (As in above situation, the Time 2 will be 11/30/2007 11:58 P.M)

Could some one please suggest if there is any function module for this case.

Thanks in Advance.

5 REPLIES 5
Read only

0 Likes
1,327

You can use this one: HRVE_GET_TIME_BETWEEN_DATES

This returns the days, months and years.

Read only

0 Likes
1,327

Sorry, i did not read your post very well.

If you want the seconds, you can use this fm one:

CALL FUNCTION 'CX_SCHED_VIA_OPERATING_TIME'

EXPORTING

i_date_start = w_fecha1

i_time_start = w_hora1

i_date_end = w_fecha2

i_time_end = w_hora2

i_unit = w_medida

IMPORTING

E_DURATION = w_horas

EXCEPTIONS

parameters_not_valid = 1

OTHERS = 2.

You can specified de date and hour and in unit, you can put H and it will return the time in hours. Then you only have to translate the hours to seconds.

Read only

former_member188829
Active Contributor
0 Likes
1,327

Hi,

Use Function Module..

SD_DATETIME_DIFFERENCE

or

SD_CALC_DURATION_FROM_DATETIME

Read only

Former Member
0 Likes
1,327

try using FM

SCOV_TIME_DIFF_46B

Read only

Former Member
0 Likes
1,327

Hi, You can use the following function module to calculate the diffrence between to dates in the unit that you want.

COPF_DETERMINE_DURATION calculates the difference between two dates and time in minutes and hours.

Parameters:

EXPORTING

I_START_DATE "The start date of the time interval

I_START_TIME "The start time of the time interval

I_END_DATE "The end date of the time interval

I_END_TIME "The end time of the time interval

I_UNIT_OF_DURATION "Time unit of the duration if not to be calculated in days.

Value ===== Meaning

' ' ===== Day (default)

D ===== Days

H ===== Hours

MIN ===== Minutes

MON ===== Months

S ===== Seconds

WK ===== Weeks

YR ===== Years

I_FACTORY_CALENDER "A factory calender if not using the Gregorian calender

IMPORTING

E_DURATION "Time difference in unit specified.

Message was edited by:

Rajesh Soman