Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

problem in adding month to date

satish_kumar127
Participant
0 Likes
1,300

Hi guru's,

actually my requirement is to add 1 month to input date which is having range (FROM DATE  and TO DATE ).

lets say, my input is for  From date is  01.04.2014  and TO Date is 30.04.2014.

and i'm expecting From Date is 01.05.2014   and TO Date is 31.05.2014 after adding month as may month contains 31 days.

in my report i have used "RE_ADD_MONTH_TO_DATE" function module. it's giving me TO date is 30.05.2014 .

could anybody please give me some idea .

Thanks in Advance.

Regards

satish

1 ACCEPTED SOLUTION
Read only

Former Member
1,244

Hi.

use this function

CALL FUNCTION 'MONTH_PLUS_DETERMINE'

  EXPORTING

    months        = '1'

    olddate       = sy-datum

IMPORTING

   NEWDATE = l_fecha .


Regards

Miguel

6 REPLIES 6
Read only

Former Member
1,245

Hi.

use this function

CALL FUNCTION 'MONTH_PLUS_DETERMINE'

  EXPORTING

    months        = '1'

    olddate       = sy-datum

IMPORTING

   NEWDATE = l_fecha .


Regards

Miguel

Read only

0 Likes
1,244

hi miguel,

Thanks for ur prompt reply,  but I've tried and failed to make this work.


As i've already mentioned in my query ,  given input is 30.04.2014 and it's giving me 30.05.2014


but i'm expecting 31.05.2014.


regards

satish

Read only

0 Likes
1,244

you are asking for 1 month from the input date.

it sounds like what you are after is the last day of the month

several ways you can do this.....

one way....take the 1st day of a month and subtract 1 from it

or use one of the many date functions, like

FKK_GET_LAST_DAY_OF_MONTH for example....only need to supply the date in and last day is returned.

Read only

0 Likes
1,244

so, what u need to do is to first count the days of the months, some months 30 or 31..then add those days to the date by normal add.

l_date1 =  01.04.2014


CALL FUNCTION 'NUMBER_OF_DAYS_PER_MONTH_GET'

  EXPORTING

    par_month       = '05'

    par_year        = '2014'

IMPORTING

   PAR_DAYS        = l_dias .


l_date = l_date1 + l_days.


Regards

Miguel

Read only

0 Likes
1,244

Hi,

add first 1 month than try FM: LAST_DAY_OF_MONTH-

regards, Dieter

Read only

0 Likes
1,244

thank u all for your valuable time and helpful replies. problem solved.