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: 

How to get name of the month from current date.

Former Member
0 Kudos

Hi,

How to get the name of the month from current date.

Thanks,

Senthil

5 REPLIES 5

Former Member
0 Kudos

MONTH_NAMES_GET

Former Member
0 Kudos

Senthilkumar,

Please also check the following thread for more info on this FM

Cheers

Raghava

0 Kudos

Hi Rahava,

for current date this function is ok.

if I want to pass a date n wanna get month of the date, which function can i use.

Thanks,

Senthil

0 Kudos

Sethil,

Use your date(let us say Date1) instead of sy-datum.

CALL FUNCTION 'MONTH_NAMES_GET'

  • EXPORTING

  • LANGUAGE = SY-LANGU

  • IMPORTING

  • RETURN_CODE =

TABLES

MONTH_NAMES = itab_month

  • EXCEPTIONS

  • MONTH_NAMES_NOT_FOUND = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

READ TABLE itab_month

WITH KEY MNR = date1+4(2).

itab_month-LTX will contain the value you are looking for

Good luck

Raghava

Former Member
0 Kudos

If you have date in some field say l_date and see below code

CALL FUNCTION 'MONTH_NAMES_GET'

  • EXPORTING

  • LANGUAGE = SY-LANGU

  • IMPORTING

  • RETURN_CODE =

TABLES

MONTH_NAMES = itab_month

  • EXCEPTIONS

  • MONTH_NAMES_NOT_FOUND = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

READ TABLE itab_month

WITH KEY MNR = l_date+4(2).

if sy-subrc = 0.

l_month = itab_month-<monthfield>

endif.

now l_month will have month.