Application Development 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: 

Period difference

Former Member
0 Kudos

Hi,

Is there any function module to calculate the difference between two periods.

(I.e, period and year combinations)

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Karthick,

Use the FM "HR_99S_INTERVAL_BETWEEN_DATES".

Sample code,

DATA : DATE1 LIKE SY-DATUM,

DATE2 LIKE SY-DATUM,

DAYS1 TYPE I,

WEEKS1 TYPE I,

MONTHS1 TYPE I,

YEARS1 TYPE I,

AGE(30) TYPE C.

DATE1 = DOB.

DATE2 = SY-DATUM.

CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'

EXPORTING

BEGDA = DATE1

endda = DATE2

IMPORTING

DAYS = DAYS1

WEEKS = WEEKS1

MONTHS = MONTHS1

YEARS = YEARS1.

Thanks,

Reward If Helpful.

4 REPLIES 4

Former Member
0 Kudos

can't you do it manually...

if years are same...simply find the difference in the periods,

if not then first find the difference in the years and then the periods.

might be possible with a simple arithmetic calculation....try it?

please let me know if i have understood you horribly wrongly!!

regards,

Priyank

Former Member
0 Kudos

Hi,

use FM : SD_DATETIME_DIFFERENCE

Jogdand M B

Former Member
0 Kudos

hi,

Use this FM.

  CALL FUNCTION 'HR_MX_INTERVAL_BETWEEN_DATES'
      EXPORTING
        I_DATE_START                = gd_start_date
        I_DATE_END                   = gd_end_date
      IMPORTING
        E_YEARS                       = gd_years
        E_DAYS                         = gd_days
      EXCEPTIONS
        SEQUENCE_OF_DATES_NOT_VALID = 1
        ERROR_IN_CALC_OF_YEARS      = 2
        NO_ENTRY_IN_T511K           = 3
        OTHERS                      = 4.
    if sy-subrc   <> 0.
    endif.

Regards

Reshma

Former Member
0 Kudos

Hi Karthick,

Use the FM "HR_99S_INTERVAL_BETWEEN_DATES".

Sample code,

DATA : DATE1 LIKE SY-DATUM,

DATE2 LIKE SY-DATUM,

DAYS1 TYPE I,

WEEKS1 TYPE I,

MONTHS1 TYPE I,

YEARS1 TYPE I,

AGE(30) TYPE C.

DATE1 = DOB.

DATE2 = SY-DATUM.

CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'

EXPORTING

BEGDA = DATE1

endda = DATE2

IMPORTING

DAYS = DAYS1

WEEKS = WEEKS1

MONTHS = MONTHS1

YEARS = YEARS1.

Thanks,

Reward If Helpful.