FORM calculate_time_diff_in_sec USING before_date LIKE sy-datum
before_time LIKE sy-uzeit
now_date LIKE sy-datum
now_time LIKE sy-uzeit
time_diff TYPE i.
DATA: delta_date TYPE i,
delta_time TYPE i.
delta_date = now_date - before_date.
delta_time = now_time - before_time.
IF delta_date < 0. " irregular situation
time_diff = 0.
ELSEIF delta_date > 2000. " avoid overflow
time_diff = 0.
ELSE.
time_diff = delta_date * 86400 + delta_time.
IF time_diff < 0. " irregular situation
time_diff = 0.
ENDIF.
ENDIF.
ENDFORM. " CALCULATE_TIME_DIFF_IN_SEC
before_time LIKE sy-uzeit
now_date LIKE sy-datum
now_time LIKE sy-uzeit
time_diff TYPE i.
DATA: delta_date TYPE i,
delta_time TYPE i.
delta_date = now_date - before_date.
delta_time = now_time - before_time.
IF delta_date < 0. " irregular situation
time_diff = 0.
ELSEIF delta_date > 2000. " avoid overflow
time_diff = 0.
ELSE.
time_diff = delta_date * 86400 + delta_time.
IF time_diff < 0. " irregular situation
time_diff = 0.
ENDIF.
ENDIF.
ENDFORM. " CALCULATE_TIME_DIFF_IN_SEC
No comments:
Post a Comment