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

Period difference

Former Member
0 Likes
1,072

Hi,

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

(I.e, period and year combinations)

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
760

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
Read only

Former Member
0 Likes
760

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

Read only

Former Member
0 Likes
760

Hi,

use FM : SD_DATETIME_DIFFERENCE

Jogdand M B

Read only

Former Member
0 Likes
760

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

Read only

Former Member
0 Likes
761

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.