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 Obtain Date in MON YYYY format i.e Jan 2013?

Former Member
0 Kudos

Hi Guys,
I want date to be in format MON YYYY i.e like Jan 2013.I searched and found all other formats but not this one.
I am extracting date from month_plus_determine Fm and need to display it in this format MON YYYY.
Can you help me with this?
Thanks.

7 REPLIES 7

Former Member
0 Kudos

Hi Dharmin,

Form a temporary internal table with months and corresponding names.(ex: 1 JAN, 2 FEB...)

You can use concatenate command to concatenate month name(read from above temp internal table) and with the year from the date you already have.

Reward if helpful.

Regards,

Mahidhar.

kakshat
Advisor
Advisor
0 Kudos

MONTH_NAMES_GET will give you the month names.

former_member491621
Contributor
0 Kudos

Hi Dharmin,

You could use a simple CASE to do the same.

Check the numeric value of month in the complete date and replace/concatenate the date in your required format into a character/string type variable.

Please see the sample code

CASE var.                         (Where var would be the month in number)

or

CASE date+4(2).

     WHEN '01'.

              CONCATENATE date(4) 'JAN'  INTO string.

     WHEN '02'......and so on.

Hope this helps

SreekanthKrishn
Contributor
0 Kudos

Hi,

Instead of using custom code, you can use the standard FM /OSP/TRVL_CONV_DATE_LNG_FORMAT.

You can give input as

IV_INPUT                        20121212

IV_LANGUAGE

IV_DATE_FORMAT                  4

  and you will get output as thjs

   EV_OUTPUT                       2012 December 12

Now, you can take the first 4 characters of year and first 3 characters of month to get the required value.

Thanks,

Sreekanth

Former Member
0 Kudos

Hi,

There are 2 ways to do it.

1. Get the Month Number using the FM : 'CACS_DATE_GET_YEAR_MONTH'

    Then get the name of the month in any language from the table : T247

2. Use FM - 'CACS_DATE_GET_YEAR_MONTH'

   Get Month Name - MONTH_NAMES_GET

   Finally use Concatenate statement and display in the way you want.

Thanks and Regards.

Rajender Patyal

Former Member
0 Kudos

DATA: ext TYPE RN1DATUM-DATEX.

USE FM 'FORMAT_DATE_4_OUTPUT'.

CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'

  EXPORTING

    datin         = SY-DATUM

    format        = 'DD-MM-YYYY'

IMPORTING

   DATEX         = ext .

WRITE: ext .

Reward point if this is useful.

Former Member
0 Kudos

Try this one also.

DATA: ext TYPE rn1datum-datex.



CALL FUNCTION 'FORMAT_DATE_4_OUTPUT'

  EXPORTING

    datin  = sy-datum

    format = 'MM-YYYY'

  IMPORTING

    datex  = ext.



DATA: srt_txt type T247-KTX ,

      srt_date type T247-MNR  .



srt_date  = ext(2).



CALL FUNCTION 'ISP_GET_MONTH_NAME'

  EXPORTING

*   DATE               = sy-datum

    language           = sy-langu

   MONTH_NUMBER       = srt_date

IMPORTING

*   LANGU_BACK         =

*   LONGTEXT           =

   SHORTTEXT          = srt_txt

* EXCEPTIONS

*   CALENDAR_ID        = 1

*   DATE_ERROR         = 2

*   NOT_FOUND          = 3

*   WRONG_INPUT        = 4

*   OTHERS             = 5


WRITE: srt_txtext+2 .