01-11-2007 6:22 AM
hi guys,
can any one tell me the difference between 2 dates in days
for eg: input 20.12.2006 and 06.11.2006 will be 34.
thanks in advance for you answers
Regards,
Anil kumar P
01-11-2007 6:35 AM
Hi Anil,
Check this code for u r requirement
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.
01-11-2007 6:24 AM
Hi,
data : v1 type i.
v1 = d1 - d2.
write v1.
If d1 and d2 hold date values of type sy-datum.
01-11-2007 6:26 AM
01-11-2007 6:25 AM
if two variables are of type d you can do by simple subtraction.
d3 = d2 - d1.
d3 also type i.
other ways you have to use fm like DAYS_BETWEEN_TWO_DATES
regards
shiba dutta
Message was edited by:
SHIBA DUTTA
01-11-2007 6:34 AM
Hi
U try this FM
SD_DATETIME_DIFFERENCE
u set the time as 12 both tme fields
hope this will help u
Thanks
Shiva
01-11-2007 6:35 AM
Hi Anil,
Check this code for u r requirement
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.
01-11-2007 6:52 AM
Hi,
Use the FM:
<b>SD_DATETIME_DIFFERENCE</b>
Give the difference in Days and Time for 2 dates
Hope this helps.
Reward if helpful.
Regards,
Sipra