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

finding the function madule

Former Member
0 Likes
1,099

hi,

i want to know the function modules which give

1.no.days between two given dates

2.no.months between two given dates

3.no.years between two gives dates

thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,029

You may want to try and Search this Forum, as this has been asked several times. I did a Search on "Days Between" and found 103 hits.

12 REPLIES 12
Read only

Former Member
0 Likes
1,030

You may want to try and Search this Forum, as this has been asked several times. I did a Search on "Days Between" and found 103 hits.

Read only

Former Member
0 Likes
1,029

Kiran,

just give appropriate term in se37 with wild char and press F4 you will get many FM use either among them.

like daybetween* press F4 and all possible term.

Amit.

Read only

Former Member
0 Likes
1,029

Chk this FM.

FIMA_DAYS_AND_MONTHS_AND_YEARS

Read only

Former Member
0 Likes
1,029

MONTHS_BETWEEN_TWO_DATES : To get the number of months between the two dates.

HR_99S_INTERVAL_BETWEEN_DATES : Difference between two dates in days, weeks, months

RP_CALC_DATE_IN_INTERVAL

Add/subtract years/months/days from a date

Read only

Former Member
0 Likes
1,029

Hi kiran,

You can use the FM HR_GET_TIME_BETWEEN_DATES to get months,years and days between two dates.

Example:-

data :
w_days type p,
w_months type p,
w_years type p.

  CALL FUNCTION 'HR_GET_TIME_BETWEEN_DATES'
    EXPORTING
      beg_date       = fs_day-f_day
      end_date       = fs_day-l_day
    IMPORTING
      months         = w_months
      days             = w_days
      years            = w_years
    EXCEPTIONS
      invalid_period = 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.                               " IF SY-SUBRC <> 0

This will definitely solve your issue.

Best of luck,

Bhumika

Read only

Former Member
0 Likes
1,029

This FM will give you all you need

HR_99S_INTERVAL_BETWEEN_DATES

Regards,

Prashant

Read only

Former Member
0 Likes
1,029

1) To get the number of months between the two dates.

use function mod

MONTHS_BETWEEN_TWO_DATES

2) To get the number of days between the two dates

Check the Fun Mod

SD_DATETIME_DIFFERENCE and

RP_CALC_DATE_IN_INTERVAL

3) To get the number of weeks between the two dates

check fun mod

HR_IE_NUM_PRSI_WEEKS

4) To get the number of years between the two dates

check fun mod

HR_HK_DIFF_BT_2_DATES

Regards

srinivas

Read only

Former Member
0 Likes
1,029

hi,

you can use these fm .

RP_CALC_DATE_IN_INTERVAL

HR_IE_NUM_PRSI_WEEKS

Read only

Subhankar
Active Contributor
0 Likes
1,029

Hi..

Please use the FM HRCO_GET_TIME_BETWEEN_DATES ..

I think it will solve ur problems..

DATA: v_date1 TYPE sy-datum,

v_date2 TYPE sy-datum,

v_days TYPE P,

v_month TYPE p,

v_year TYPE p.

v_date1 = sy-datum.

v_date2 = '20100826'.

CALL FUNCTION 'HRCO_GET_TIME_BETWEEN_DATES'

EXPORTING

beg_date = v_date1

end_date = v_date2

IMPORTING

DAYS = v_days

MONTHS = v_month

YEARS = v_year

EXCEPTIONS

INVALID_PERIOD = 1

OTHERS = 2

.

IF sy-subrc = 0.

WRITE : / v_days, v_month, v_year.

ENDIF.

Read only

shadow
Participant
0 Likes
1,029

Hi ,

hope dis is use full for u..................

HR_GET_TIME_BETWEEN_DATES

HR_99S_INTERVAL_BETWEEN_DATES

Regard's

Shaik.

Read only

UmaArjunan
Active Participant
0 Likes
1,029

Run this report. This will exactly match your requirement.

I searched this from the net. copy the code and check in your system by giving two inputs start date and end date to calculated no of days,months and year

REPORT ZDATEDIFF.

DATA: EDAYS LIKE VTBBEWE-ATAGE,

EMONTHS LIKE VTBBEWE-ATAGE,

EYEARS LIKE VTBBEWE-ATAGE.

PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,

TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.

call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

exporting

i_date_from = FROMDATE

i_date_to = TODATE

  • I_FLG_SEPARATE = ' '

IMPORTING

E_DAYS = EDAYS

E_MONTHS = EMONTHS

E_YEARS = EYEARS.

WRITE:/ 'Difference in Days ', EDAYS.

WRITE:/ 'Difference in Months ', EMONTHS.

WRITE:/ 'Difference in Years ', EYEARS.

INITIALIZATION.

FROMDATE = SY-DATUM - 60.

Read only

Former Member
0 Likes
1,029

Hi Kiran,

Try this FM's:

SD_DATETIME_DIFFERENCE

Give the difference in Days and Time for 2 dates

HR_IE_NUM_PRSI_WEEKS

Return the number of weeks between two dates.

RP_CALC_DATE_IN_INTERVAL

Add/subtract years/months/days from a date

With luck,

Pritam.