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: 

getting month

Former Member
0 Kudos

Hi,

How do I get Month from creation date.

If Creation date is 05/01/2004 then I want month as 05.

Thanks

Veni.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Here we are using substrings. The line of code below means that you what the value starting four characters to the left, and the following 2 characters.



data: month(2) type n.

month = creation_date+4(2).


Regards,

Rich Heilman

5 REPLIES 5

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Here we are using substrings. The line of code below means that you what the value starting four characters to the left, and the following 2 characters.



data: month(2) type n.

month = creation_date+4(2).


Regards,

Rich Heilman

Former Member
0 Kudos

Veni,

VBAK-ERDAT+4(2) will give you the month.

I have given the sample code you were looking for in the other thread.

Regards,

Ravi

Note : Please mark the helpful answers

Former Member
0 Kudos

Hi Veni,

try this...

data: month(2) .

month = creation_date+0(2).

Regards,

Tanveer.

<b>Please mark helpful answers</b>

Preety much..Thanks..All i considered was the above case..

Thanks..

0 Kudos

Because all dates in R/3 are stored in the database and in memory as YYYYMMDD, not like the external format 05/01/2004. So at runtime, in order to access the month, you must move 4 places to the left and get the next two characters. Make sense?

Regards,

Rich Heilman

0 Kudos

Hi Veni,

In SAP the date will be in the 20040501(YYYYMMDD) format.

For example if the creation date is 05/01/2004 it will be stored as 20060510 in SAP.To get the month use the substring.

data : Month(2).

Month = date+4(2)

This will give you the month 05.

Rgds,

Rama