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

TIME

Former Member
0 Likes
1,385

Hi Everybody,

I have The variables like,

Data : time1 like sy-uzeit value '102030',

time2 like sy-uzeit '102530'.

now I wants the difference between two times. If any Function module is there to do it. Thanks in Advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,332

Just use Subtraction Operator between two variables.

Thanks,

Prashanth

12 REPLIES 12
Read only

Former Member
0 Likes
1,331

Check

SD_DATETIME_DIFFERENCE

SCOV_TIME_DIFF_46B

Read only

0 Likes
1,331

u dont need a fm i think try this

data: time1 type sy-uzeit value '102030'.

data: time2 type sy-uzeit value '102530'.

time2 = time2 - time1.

write: time2.

santhosh

Read only

Former Member
0 Likes
1,331

Hello,

L_MC_TIME_DIFFERENCE : Find the time difference between two date/time

Vasanth

Read only

Former Member
0 Likes
1,331
try this

call function 'SD_DATETIME_DIFFERENCE'
           exporting
*                DATE1            = sy-datum
                 date1            = sy-datum
                time1            = time1
                date2            = dt_dlvy-wadat
                time2            = sy-uzeit
           importing
                datediff         = datediff
                timediff         = timediff
                earliest         = earliest
           exceptions
                invalid_datetime = 1
                others           = 2.
Read only

0 Likes
1,331

Thanks Chandrasekar. I rewarded points to you and I have one more doubt. That is what is the use of " Earliest " parameter.

Thanks.

Read only

0 Likes
1,331

Vijay,

Earliest parameter tells you which one of the entered DATE TIME is greater. If the DATE1 TIME1 is greater than the DATE2 TIME2 it is set to '1'. Else it is '2'. If both are same it is set to '0'.

Thanks

Read only

0 Likes
1,331

Hi vijay,

Earliest can have the values 0 , 1 and 2

If both the dates are equal , then it is 0

if date1 > date 2 , earliest is 2

if date2 > date1 , earliest is 1

Read only

Former Member
0 Likes
1,333

Just use Subtraction Operator between two variables.

Thanks,

Prashanth

Read only

Former Member
0 Likes
1,331

hi Vijay,

Use FM SD_DATETIME_DIFFERENCE

Regards,

Santosh

Read only

Former Member
0 Likes
1,330

Example of a time calculation:

DATA: diff      TYPE i,
      seconds TYPE i,
      hours   TYPE i.

DATA: t1 TYPE t VALUE '200000',
      t2 TYPE t VALUE '020000'.

diff = t2 - t1.
seconds = diff MOD 86400.
hours = seconds / 3600.

The number of hours between 02:00:00 and 20:00:00 is calculated.

· First, the difference between the time fields is calculated. This is -64800, since t1 is converted internally to 72000 and t2 to 7200.

· Then, with the operation MOD, this negative difference is converted to the total number of seconds. A positive difference would be unaffected by this calculation.

· Third, the number of hours is calculated by dividing the number of seconds by 3600.

The last three lines can be replaced by the following line

HOURS = ( ( t2 - t1) MOD 86400) / 3600.

Read only

Former Member
0 Likes
1,330

Hi Vijay,

Try FM <b>SALP_SM_CALC_TIME_DIFFERENCE</b>

reward if useful.

Read only

Former Member
0 Likes
1,330

Hi,

Use this FM:

/SDF/CMO_TIME_DIFF_GET

Regards

Shiva