‎2008 May 19 12:48 PM
How to add 5 months to date field.
For ex: To find out the date after 5 months from today.
‎2008 May 19 12:52 PM
Hi,
Use the following function module:
MONTH_PLUS_DETERMINE :Add or subtract months from a date. To subtract a month, enter a negative value for the 'months' parameter.
Example:
data: new_date type d.
CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
months = -5 " Negative to subtract from old date, positive to add
olddate = sy-datum
IMPORTING
NEWDATE = new_date.
write: / new_date.
Regards,
Shiva Kumar
‎2008 May 19 12:50 PM
‎2008 May 19 12:52 PM
Hi,
Use the following function module:
MONTH_PLUS_DETERMINE :Add or subtract months from a date. To subtract a month, enter a negative value for the 'months' parameter.
Example:
data: new_date type d.
CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
months = -5 " Negative to subtract from old date, positive to add
olddate = sy-datum
IMPORTING
NEWDATE = new_date.
write: / new_date.
Regards,
Shiva Kumar
‎2008 May 19 12:56 PM
hi there...
i hav seen this qstn many a times and the ways people devise to get past this. But i dont understand y dont u look for better and easier ways of getting over problems.
Anyways, i would suggest you to declare a variable of type p and put in the date in it. Then simply add the number of days to this. This will solve your query. I am not putting in the entire code, as i dont feel it will be in your interest. Try going ahead with this much hint and u wil find your way out.
Do reward if helpful or get back if still facing any issues.
‎2008 May 20 12:32 PM
hi prem,
how do u know that how many days to add.
the no. of days in a month can change for ex: for FEB
and when u dont know on which day you will run the program, then how do u calculate the no.of days
‎2008 May 19 12:56 PM
Hi,
Call function 'BCA_US_DATES_CALC_DATE'
exporting i_start_date = <old_date>
i_term = <month>
i_periodunit = '3'
importing e_end_date = <new_date>
Cheers.
...Reward if useful.
‎2008 May 19 12:58 PM
hi,
use the fm
DATE_IN_FUTURE : Calculate a date N days in the future.
Program:
PARAMETERS: p_days TYPE i, " Number days that are added/subtracted
p_date TYPE eeind. " Date to which NUMBER_DAYS is added
DATA: addin_date TYPE sy-datum, " Determined date in the internal format
addex_date(10) TYPE c. " Determined date in external format
CALL FUNCTION 'DATE_IN_FUTURE'
EXPORTING
anzahl_tage = p_days
import_datum = p_date
IMPORTING
export_datum_ext_format = addex_date
export_datum_int_format = addin_date.
WRITE:/5 'date in the internal format: ', addin_date ,
/5 'Determined date in external:', addex_date.
MONTH_PLUS_DETERMINE - Add or subtract months from a date. To subtract a month, enter a negative
parameters: date type SYDATUM, " date
months type i. " no of months to add/subtract ,
use '-' for subtraction.
data: newdate type SYDATUM.
CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
months = months
olddate = date
IMPORTING
NEWDATE = newdate
.
write:/ 'old date:', date.
write:/ 'new date:', newdate.
regards
prasanth
‎2008 May 19 1:03 PM
Hi,
look at the Below FM's, you can use one of those..
MONTH_PLUS_DETERMINE--> Add or subtract months from a date. To subtract a month, enter a negative value for the 'months' parameter.
codedata: new_date type d.
CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
months = 5
olddate = sy-datum
IMPORTING
NEWDATE = new_date.
write: / new_date.[/code]
You can use RE_ADD_MONTH_TO_DATE also
You can Also use the FM 'RP_CALC_DATE_IN_INTERVAL'
sample code
data: date like sy-datum,
date1 like sy-datum.
date = sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = date
days = 00
months = 02 "no of months
SIGNUM = '+' "months added
years = 00
IMPORTING
CALC_DATE = date1. " new date
write:/ 'new date', date1.[/code]
Regards,
Raj.
‎2008 May 19 1:05 PM
Hi,
Use any of the following function modules.
SG_PS_ADD_MONTH_TO_DATE Add months to the date
MONTH_PLUS_DETERMINE Add months to the date
BKK_ADD_MONTH_TO_DATE Add months to the date
RE_ADD_MONTH_TO_DATE Add months to the date
HR_PSD_DATES_ADD_MONTHS Add months to the date
HR_HCP_ADD_MONTH_TO_DATE Add months to the date
HR_JP_ADD_MONTH_TO_DATE Add months to the date, Minus months from date
HR_BR_ADD_MONTH_TO_DATE Add months to the date, Minus months from date
HR_PT_ADD_MONTH_TO_DATE Add months to the date, Minus months from date
‎2008 May 19 1:08 PM
Hi,
You can use FM RP_CALC_DATE_IN_INTERVAL, input your date in date, months - no. of mnths to be increased, signum to be '+'.
Thanks,
Sriram Ponna.
‎2008 May 19 1:10 PM
hi charan,
just add 5 to your date field.
for example:
v_date = '20080519'. "today's date in YYYYMMDD
v_date = v_date+4(2) + 5.
regards,
Peter
‎2008 May 20 12:37 PM
‎2016 Jun 27 10:44 PM