cancel
Showing results for 
Search instead for 
Did you mean: 

FM: Period in Time Between Two Dates

eyal_alsheikh
Active Participant
0 Kudos

Hi,

I am looking for function module that recieves two dates

as import and return the period between them in years or months.

Thanks,

Eyal.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Check with this FM

'CSCP_PARA1_GET_PERIODS'

Thanks.

former_member181962
Active Contributor
0 Kudos

HI Eyal,

I've just tried in my system, its working

REPORT YRT_TEST1.

parameters : date1 like sy-datum,

date2 like sy-datum.

data: days(3) type n.

data: years(10) type p decimals 3.

start-of-selection.

days = date2 - date1.

years = days / 365.

write: / days,

years.

Answers (4)

Answers (4)

eyal_alsheikh
Active Participant
0 Kudos

Hi Ravi,

I tried your suggestion but it does not worked

for me.

Eyal.

eyal_alsheikh
Active Participant
0 Kudos

Hi,

Is there FM like that if I give it two dates:

first date: 01.01.2006

second date: 01.02.2006

years: 0.083 years.

former_member181962
Active Contributor
0 Kudos

Hi Eyal,

I don't know if there is an FM, but what you can do is

data: years(10) type P decimals 3,

days(3) type n.

days = date1 - date2.

years = days / 365.

Thanks and regards,

Ravi

Former Member
0 Kudos

Hi,

Sample code for the function module you want.

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.

Regards,

Sailaja.

former_member181962
Active Contributor
0 Kudos

EHS_CALC_YEARS_BETWEEN_DATES

DAYS_BETWEEN_TWO_DATES

MONTHS_BETWEEN_TWO_DATES

HR_99S_INTERVAL_BETWEEN_DATES(Months, Years and days)

COMPUTE_YEARS_BETWEEN_DATES