04-03-2006 11:01 AM
Hi,
I need to sustract 2 dates and obtain the differece of days.
My question is that if I need to do some convertion first or direct sustract the 2 dates and obtain the result in days?
Ex: 02.03.06 - 31.03.06 = 2
04-03-2006 11:03 AM
Hi laura,
1. no need to do anything special.
2. just simply minus.
3. eg.
report abc.
data : d1 type sy-datum,
d2 type sy-datum.
data : diff type i.
d1 = '20060101'.
d2 = '20060331'.
diff = d2 - d1.
write : diff.
regards,
amit m.
04-03-2006 11:02 AM
Hi Laura,
you don't need to do any convesrion.
data: v_diff_in_days type i.
data: v_date1 like sy-datum value '20060202'.
data: v_date2 like sy-datum value '20060101'.
v_diff_in_days = v_date1 - v_date2.
write: v_diff_in_days.
P.S: the dates that are to be subtracted must be of type sy-datum,If they are not in the internal format, then convert the external format Date into internal format using the FM CONVERT_DATE_TO_INTERNAL and then subtract.
Regards,
Ravi
04-03-2006 11:03 AM
Hi laura,
1. no need to do anything special.
2. just simply minus.
3. eg.
report abc.
data : d1 type sy-datum,
d2 type sy-datum.
data : diff type i.
d1 = '20060101'.
d2 = '20060331'.
diff = d2 - d1.
write : diff.
regards,
amit m.
04-03-2006 11:06 AM
04-03-2006 11:05 AM
Hi,
you can directly substarct .
data: date1 like sy-datum,
datt2 like sy-datum.
date1 = sy-datum.
date2 = sy-datum - 7.
diff = date1 - date2.
Regards
vijay
04-03-2006 11:05 AM
hi laura,
directly u can subtract
REPORT YCHATEST .
data : date1 like sy-datum,
date2 like sy-datum,
dif type i.
date1 = '20060403'.
date2 = '20060401'.
dif = date1 - date2.
write : / dif.
04-03-2006 11:09 AM