Application Development 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: 

Get last day in a month

Former Member
0 Kudos

I want to get the last date in a month. I let the user choose a date, for example 20050509 and want the "result" to be 20050531.

16 REPLIES 16

Former Member
0 Kudos

Hi

there are several fm find out the last day of month:

LAST_DAY_OF_MONTHS

RE_LAST_DAY_OF_MONTH for example

Max

Message was edited by: max bianchi

0 Kudos

Sounds nice. Is it function modules, so I can write it in SE37 and get more information?

0 Kudos

Hi

Yes you can try these function by SE37.

But they want a date and then they return last day:

PARAMETER MY_DATE LIKE SY-DATUM.

DATA: LAST_DAY LIKE SY-DATUM.

CALL FUNCTION 'LAST_DAY_OF_MONTHS'

EXPORTING

DAY_IN = MY_DATE

IMPORTING

LAST_DAY_OF_MONTH = LAST_DAY.

WRITE LAST_DAY.

Max

Message was edited by: max bianchi

Message was edited by: max bianchi

0 Kudos

I write LAST_DAY_OF_MONTHS in SE37, but do not get any result. Any idea what I do wrong?

0 Kudos

Hi

the function are:

LAST_DAY_OF_MONTHS

RE_LAST_DAY_OF_MONTH

Which your release is?

Max

Former Member
0 Kudos

Hi,

data: date type d.

date = sy-datum.

date+6(2) = '01'.

date = date + 31.

date+6(2) = '01'.

date = date - 1.

Svetlin

0 Kudos

Just a question.

What does 6(2) mean?

0 Kudos

Hi

the format of day is YYYYMMDD, so

DATE+6(2) is DD,

DATE+4(2) is MM

DATE(4) is YYYY

Max

Former Member
0 Kudos

Hi,

You can also use NUMBER_OF_DAYS_PER_MONTH_GET to get the number of days in any month.

The last day will of course be the last date for the month. This FM also works for leap yrs.

Sudha

Former Member
0 Kudos

Hi,

Further to this if you want to find the name of the day

that LAST_DAY_OF_MONTHS gives out use the FM

<b>RH_GET_DATE_DAYNAME</b>.

Ex:

For today's date <b>09/28/2005</b> it gives out

<b>Wednesday</b>.

Please reward points if you find this explanation useful.

Regards,

Siva

Former Member
0 Kudos

Also u can do as

DATA: ws_c_date(8)  TYPE c,

s_date = '20050509'
p_list = s_date+6(2).
p_list1 = s_date+0(4).

  CALL FUNCTION <b>'NUMBER_OF_DAYS_PER_MONTH_GET'</b>
         EXPORTING
              par_month = p_list
              par_year  = p_list1
         IMPORTING
              par_days  = ws_n_days.

<i>*  For Concatenating the month and year into the date format</i>

CONCATENATE  p_list1  p_list ws_n_days INTO ws_c_date.

Hope this too helps u.

Kindly reward points for the helpful answer and close the thread.

0 Kudos

Hi,

Here's example how you can use FM RE_LAST_DAY_OF_MONTH:

data: w_last_day(2) type c.

CALL FUNCTION 'RE_LAST_DAY_OF_MONTH'
  EXPORTING
    I_DATUM        = sy-datum
 IMPORTING
*   E_KZ_ULT       =
   E_TT            = w_last_day
          .
write: w_last_day.

Regards,

Ville

Former Member
0 Kudos

I have now solved it. Thanks everybody!

0 Kudos

Hi Linn,

SDN way of saying thanks can be found here

/people/mark.finnern/blog/2004/08/10/spread-the-love

Regards

Raja

0 Kudos

If your question has been solved, please close the thread and kindly award points for helpful answers.

Svetlin

0 Kudos

> I have now solved it. Thanks everybody!

Hi Linn,

If you found any of these answers useful please close the post and reward points.

Regards,

Ville