10-09-2006 12:48 PM
hi intelectuals
actually im pointing down certain issues tht im facin in date calculations in terms of examples.
1) subtracting 31/09/2006 and 25/08/2006.whats d output.
2) date is 12/09/2006.if i add 12(number) to it will it bcome 24/09/2006.or if i subtract 10 from it will it bcome 2/9/2006.
im not able to understand dese date calculations
hope i get d solution asap.
10-09-2006 1:05 PM
HI
> 1) subtracting 31/09/2006 and 25/08/2006.whats d
> output.
<b> Generally while doing the subtraction, date in past will be subtracted from date i.e latest
Here in your case it is 20060930 - 20060825 = returns the days in between.</b>
> 2) date is 12/09/2006.if i add 12(number) to it will
> it bcome 24/09/2006.or if i subtract 10 from it will
> it bcome 2/9/2006.
<b> Integer that is used to manipulate a date is treated as the number of days for addition or subtraction.</b>
Lastly my friend there is no 31st in the month of September.
Kind Regards
Eswar
10-09-2006 1:12 PM
Hi vishwanath,
in ABAP the operators + and - are defined to work with data type D (date). That means, you add or subract the number of days to (or from) a given date and get the resulting date according to our (gregorian) calendar.
Subtracting an earlier from a later date gives the number of days between. The resulting variable shoul be numeric, not date:
<pre>
data:
lv_dat1 type sy-datum value '20060930',
lv_dat2 type sy-datum value '20060825',
lv_int type i .
lv_int = lv_dat1 - lv_dat2.
</pre>
results in 36 (days) for variable lv_int.
Note:
31/09/2006 is not valid as september is defined with 30 days (ABAP knows!).
Regards,
Clemens
10-09-2006 1:12 PM
Hi,
1). subtracting 31/09/2006 and 25/08/2006.whats d output?
Number of days will be given.
2). date is 12/09/2006.if i add 12(number) to it will it bcome 24/09/2006.or if i subtract 10 from it will it bcome 2/9/2006?
To get this u can also use FM 'RP_CALC_DATE_IN_INTERVAL' in which you can pass the number of days in 'days' and + or - in 'signum'.
Hope this migh thelp u.
Thanks,
Prashanth
10-09-2006 1:14 PM
The output of difference between two dates returns the number of days between the two. So the result is number of days.
Secondly when you add or subtract a number from a date field it considers the number to be days and does the required addition or subtraction.
Regards
Anurag
10-09-2006 1:20 PM
Hi,
1) subtracting 31/09/2006 and 25/08/2006.whats d
output.
system stores date in format 20060931(yyyymmdd)
and subtracts 20060825 to return no of days
between them i.e 36
2) lv_date = sy-datum + 12 will add 12 days to system
date.
lv_date = 20061009 + 12 = 20061021.
Regards
amole