‎2008 Mar 14 9:51 AM
Hi,
I want to subtract the two dates and get the no of days between them.
For ex: 20080314(YYYYMMDD) - 20031102
I want to get no of days between these two dates
Can anyone help on these
Thanks in advance.
‎2008 Mar 14 9:53 AM
just subtract one date from other ...
data : v_date1 like sy-datum,
v_date2 like sy-datum.
data : v_diff type i.
v_diff = v_date2 - v_date1.
‎2008 Mar 14 9:53 AM
Hi,
if the variables which are holding these variables are sy-datum or some other date types then u can do direct subtraction.
rgds,
bharat.
‎2008 Mar 14 9:53 AM
just subtract one date from other ...
data : v_date1 like sy-datum,
v_date2 like sy-datum.
data : v_diff type i.
v_diff = v_date2 - v_date1.
‎2008 Mar 14 10:02 AM
‎2008 Mar 14 9:53 AM
Hello,
Use this sample code:
data: G_F_DIFF TYPE I
CLEAR G_F_DIFF.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
I_DATUM_BIS = G_T_PURO-AEDAT
I_DATUM_VON = G_T_EBAN-BADAT
IMPORTING
E_TAGE = G_F_DIFF
EXCEPTIONS
DAYS_METHOD_NOT_DEFINED = 1
OTHERS = 2.
write: g_F_diff.
Cheers,
Vasanth
‎2008 Mar 14 9:54 AM
Hi,
Use the FM : 'DAYS_BETWEEN_TWO_DATES'
data: G_F_DIFF TYPE I
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
I_DATUM_BIS = G_T_PURO-AEDAT " Enddate
I_DATUM_VON = G_T_EBAN-BADAT " Start Date
IMPORTING
E_TAGE = G_F_DIFF
EXCEPTIONS
DAYS_METHOD_NOT_DEFINED = 1
OTHERS = 2.
write: g_F_diff.
Please reward points if useful.
Regards
Rose
‎2008 Mar 14 9:55 AM
‎2008 Mar 14 9:56 AM
hi,
you can add/subtract dates directly if the type is SY-DATUM.
‎2008 Mar 14 10:00 AM
Hi,
Check this code,
data: date type i.
date = 20080314 - 20031102.
write: / date.
Thats it. !!..
You can also have the date fields in two variables if you want to.
Reward if helpful.
Regards.