I have been given an assignment like this:
I will have a selection screen input box where user enters date and an other input box where he enters number of months.
I have to do is add the given number of months to date and get the new date.
Example: If entered date is 2/3/2011
and given number of months are 5
i should get 7/3/2011
.
I know that system date variable 'SY-DATUM' has application server date.
And to do date manipulation i can say SY-DATUM + 2
.i can only add days,how should i add months.
Please give me a head start.Thanks.
An easy way to add a number of months to a date is to use the MONTH_PLUS_DETERMINE
function module.
Use something like:
data: mydate type sy-datum.
mydate = sy-datum.
call function 'MONTH_PLUS_DETERMINE'
exporting
MONTHS = 5
OLDDATE = mydate
importing
NEWDATE = mydate.
(MONTHS
can be negative if you want to subtract.)
There are a lot of other helper functions for date and time calculations. Useful ABAP Function Modules on the SDN Wiki is a good place to go when you're looking for things like that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With