2006 Jan 19 10:49 AM
Hi.
I need a function where you can input 2 dates and it returns the difference between them like that :
Days : ..
Months : ..
For exemple : 18.01.2006 & 19.02.2006 and it returns : 1 day and 12 months.
I already have a solution from my own <b>but</b> i will have to use a <u>standard</u> function instead of mine ... if something like that exists. ^^
Anybody have ever use something like that ?
Thanks for the help !!
FUNCTION zcalcul_ecart_date.
*"----------------------------------------------------------------------
*"*"Interface locale :
*" IMPORTING
*" REFERENCE(I_DATE_DEB) LIKE SY-DATUM
*" REFERENCE(I_DATE_FIN) LIKE SY-DATUM
*" EXPORTING
*" REFERENCE(ENBJOURS) TYPE I
*" REFERENCE(ENBMOIS) TYPE I
*"----------------------------------------------------------------------
w_date_deb = i_date_deb.
w_date_fin = i_date_fin.
CLEAR w_date_suiv.
CLEAR w_nb_mois.
CLEAR w_nb_jrs_rest.
IF w_date_deb+4(2) <> w_date_fin+4(2).
w_date_suiv = w_date_deb.
PERFORM ajout_mois CHANGING w_date_suiv.
DO.
IF w_date_suiv <= w_date_fin.
w_nb_mois = w_nb_mois + 1.
IF w_date_suiv = w_date_fin.
EXIT.
ENDIF.
PERFORM ajout_mois CHANGING w_date_suiv.
ELSE.
EXIT.
ENDIF.
ENDDO.
IF w_date_suiv+4(2) = w_date_fin+4(2).
IF w_date_suiv+6(2) <> w_date_fin+6(2).
PERFORM retrait_mois CHANGING w_date_suiv.
PERFORM calcul_nb_jrs_mois USING w_date_suiv
CHANGING w_nb_jrs_mois.
IF w_nb_jrs_mois > w_date_suiv+6(2).
w_nb_jrs_rest = w_nb_jrs_mois - w_date_suiv+6(2).
ENDIF.
w_nb_jrs_rest = w_nb_jrs_rest + w_date_fin+6(2).
ENDIF.
ELSE.
w_nb_jrs_rest = w_date_fin+6(2) - w_date_suiv+6(2).
ENDIF.
ELSE.
w_nb_jrs_rest = w_date_fin+6(2) - w_date_deb+6(2).
w_nb_mois = 0.
ENDIF.
enbjours = w_nb_jrs_rest.
enbmois = w_nb_mois.
ENDFUNCTION.
2006 Jan 19 10:52 AM
check one of the following
SD_DATETIME_DIFFERENCE
HR_HK_DIFF_BT_2_DATES
2006 Jan 19 10:57 AM
2006 Jan 19 11:07 AM
Hi,
check this FM FIMA_DAYS_AND_MONTHS_AND_YEARS
the same output with parameters..
Import parameters Value
I_DATE_FROM 10/10/2004
I_KEY_DAY_FROM 00
I_DATE_TO 10/10/2005
I_KEY_DAY_TO 00
I_FLG_SEPARATE
Export parameters Value
E_DAYS 365
E_MONTHS 12
E_YEARS 1
regards
vijay
2006 Jan 19 10:56 AM
2006 Jan 19 11:01 AM
Few more Fms
FIMA_DAYS_BETWEEN_TWO_DATES_2
DAYS_BETWEEN_TWO_DATES
COMPUTE_YEARS_BETWEEN_DATES
HR_99S_INTERVAL_BETWEEN_DATES Get days,weeks, months and years between dates
HR_99S_MONTHS_BETWEEN_DATES Get months between dates
2006 Jan 19 3:04 PM
It's always a bit dangerous trying to determine the number of days <b>and</b> months between two dates. For example, is the difference between 2006.03.31 and 2008.02.28 one month or one month and three days?
Rob
2006 Jan 19 4:26 PM
Hi,
Try these two function modules as per u r requirement...
SD_DATETIME_DIFFERENCE
RP_CALC_DATE_IN_INTERVAL
Regards,
Azaz Ali Shaik.