‎2008 Feb 04 12:36 PM
hi,
Iam using function module DAYS_BETWEEN_TWO_DATES to calculate and place the difference between 2 dates in a variable
it's working well for all dates except 31st jan2008 and 30th jan 2008 . The difference between these 2 dates should be 1.But iam unable to get the output.Please do the needful
‎2008 Feb 04 12:41 PM
‎2008 Feb 04 12:43 PM
Hi,
You don't need this function module (which has status 'not released') to find the difference in days between two dates. Just subtract one date from the other and the result will be the difference in days.
Regards,
Nick
‎2008 Feb 04 12:44 PM
Hi,
you can use FIMA_DAYS_AND_MONTHS_AND_YEARS, Try this FM also HR_HK_DIFF_BT_2_DATES.
Check this sample code
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,
Satish
‎2008 Feb 04 12:55 PM
Hi,
DATA: s_date like VTBBEWE-DBERBIS,
e_date like VTBBEWE-DBERVON.
s_date = '20080130'.
e_date = '20080131'.
DATA: diff type i.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
I_DATUM_BIS = s_date
I_DATUM_VON = e_date
*set End Date is included flag I_KZ_INCL_BIS
I_KZ_INCL_BIS = '1'
IMPORTING
E_TAGE = diff
write:/ diff.
output: 1
Reward if Helpful.
Edited by: prosenjit chaudhuri on Feb 4, 2008 1:56 PM
‎2008 Feb 04 12:56 PM
Try like this...
DATA : l_tage(5).
DATA :date1 LIKE VTBBEWE-DBERBIS value '20080131'.
DATA : date2 LIKE VTBBEWE-DBERVON value '20080130'.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = date1
i_datum_von = date2
I_KZ_EXCL_VON = '0'
I_KZ_INCL_BIS = '1' "<<<<<<<< include end date
IMPORTING
E_TAGE = l_tage.
WRITE :/ l_tage.