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: 

To get month number

Former Member
0 Kudos

Hi all ,

We have a requirement to get Month number "not an name" from the DATE,e.g IF date is 02/04/2008 we need a FM which can generate month number as '02'.

Thanks and Regards,

Priya

1 ACCEPTED SOLUTION

Former Member
0 Kudos

use like that

month_number = s_date+4(2).

rgds

rajesh

12 REPLIES 12

Former Member
0 Kudos

use like that

month_number = s_date+4(2).

rgds

rajesh

former_member787646
Contributor
0 Kudos

Hi

Try this...

Data: date1 type D.

Data: mon(2) type N.

date1 = sy-datum.

mon = date+4(2).

Write:/ mon, date1.

Hope it helps.

Murthy

Former Member
0 Kudos

Hi,

Check this code.


REPORT z_sdn.

PARAMETERS:
  p_date TYPe sy-datum.


DATA:
  w_date TYPE sy-datum,
  w_temp(2) TYPE n.

w_date = p_date.
w_temp = w_date+4(2).

WRITE:
  w_temp.

Regards

Abhijeet

Former Member
0 Kudos

Hi,

Is you date format fixed? to mm/dd/yyyy?

If yes then refer to Rajesh's solution..

Regards,

Sagar.

former_member181995
Active Contributor
0 Kudos
Data: month type N.
month = Data+0(2).

Amit.

Former Member
0 Kudos

hi,

try this Function module

FUNCTION MONTH_NAMES_GET.

*"----


Lokale Schnittstelle:

IMPORTING

VALUE(LANGUAGE) LIKE SY-LANGU DEFAULT SY-LANGU

EXPORTING

VALUE(RETURN_CODE) LIKE SY-SUBRC

TABLES

MONTH_NAMES STRUCTURE T247

EXCEPTIONS

MONTH_NAMES_NOT_FOUND

Regards,

Anirban

Former Member
0 Kudos

Hi Supriya,

Pls check FM : CACS_DATE_GET_YEAR_MONTH

Regards,

Suresh.S

Former Member
0 Kudos

Hi Supriya Nagotkar,

No need for any function module for that just take the offset of the data.

See the follwoing.

w_month = w_date+4(2).

Regards,

Mahi.

Former Member
0 Kudos

Hi,

Either we can use FM or coding is also enough

DATA: P_DATE TYPE SY-DATUM DEFAULT SY-DATUM.

l_MONTH = P_DATE+04(02).

or

Use Fumction Module " CACS_DATE_GET_YEAR_MONTH "

CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH'
 EXPORTING
   I_DATE        =    P_DATE
 IMPORTING
   E_MONTH       = L_MONTH

.

Thanx,

dhanashri.

former_member188685
Active Contributor
0 Kudos

Function module used is

HR_IN_GET_DATE_COMPONENTS

input the date and get the month number

Import parameters               Value

 IDATE                           20080208


 Export parameters               Value

 DAY                             08
 MONTH                           02 "<---month number
 YEAR                            2008
 STEXT                           FEB
 LTEXT                           February
 USERDATE                        08.02.2008

Former Member
0 Kudos

Hi ...

As Your question is answered please do Close the thread...

regards,

sg

Former Member
0 Kudos

Hi,

Just go through this it may help u....

REPORT ZASHU_MONTH_NAMES_GET.

data:r_code type sy-subrc.

data:mnames type standard table of T247 with header line.

CALL FUNCTION 'MONTH_NAMES_GET'

EXPORTING

LANGUAGE = SY-LANGU

IMPORTING

RETURN_CODE = r_code

TABLES

month_names = mnames.

  • 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.

CASE mnames.

when 'January'

..

when 'February'.

...

endcase.

Thanks & Regards

Ashu Singh