Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

difference between two dates

Hi,

how to find the differnce between two dates?(have to get no of days)

date format will be in this format yyyymmdd.

Regards

Ajay

Tags:
Former Member
Former Member replied

FM:HR_HK_DIFF_BT_2_DATES

Or

Check this Example..

DATA:DATE1 TYPE D VALUE '20071220'.

DATA:DATE2 TYPE D VALUE '20071120'.

DATA:DAYS TYPE I.

CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'

EXPORTING

I_DATUM_BIS = DATE1

I_DATUM_VON = DATE2

I_KZ_EXCL_VON = '0'

I_KZ_INCL_BIS = '0'

I_KZ_ULT_BIS = ' '

I_KZ_ULT_VON = ' '

I_STGMETH = '0'

I_SZBMETH = '1'

IMPORTING

E_TAGE = DAYS

EXCEPTIONS

DAYS_METHOD_NOT_DEFINED = 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.

Write:/ DAYS

Reward points..

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question