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: 

Date format

Former Member
0 Kudos

Hi experts,

I am getting the date in the form 06/20/2007 i wanted to convert this format into

june 20,2007, could any body tell me the best way to do this.

Thanks in advance.

Thanks,

Sarala.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Check output my code.

this converts the month number to month name and displays.its fetched from table T247.

TYPES:    BEGIN OF ty_month,
          mnr TYPE fcmnr,
          ktx TYPE fcltx,
          END OF ty_month.

DATA : w_ltx(10)   TYPE c,
       w_mnr(2)    TYPE c,
       w_date      TYPE string.

PARAMETERS : pr_date TYPE sy-datum.

******* Month Text for AI letter
    SELECT SINGLE ltx
    FROM t247
    INTO w_ltx
    WHERE spras = sy-langu
      AND   mnr = w_mnr.

    CONCATENATE pr_date+6(2) w_ltx pr_date(4) INTO w_date separated by space.

Hope this helps u.

*****Reward points if helpful.

All the best

9 REPLIES 9

Former Member
0 Kudos

It better you handle by code itself. Declare constant for month names and apply logic accordingly.

Former Member
0 Kudos

hi

u will get lot of FM in SDN itself. hope they will help u lot

regards

ravish

<b>reward if useful</b>

Former Member
0 Kudos

Hi

From the given data separate the MONTH,DATE and YEAR

take the Month and get the description of month from T247 Table

then concatenate the Month description date,year into a string and use

it's simple

Reward points for useful Answers

Regards

Anji

Former Member
0 Kudos

Hi,

Check output my code.

this converts the month number to month name and displays.its fetched from table T247.

TYPES:    BEGIN OF ty_month,
          mnr TYPE fcmnr,
          ktx TYPE fcltx,
          END OF ty_month.

DATA : w_ltx(10)   TYPE c,
       w_mnr(2)    TYPE c,
       w_date      TYPE string.

PARAMETERS : pr_date TYPE sy-datum.

******* Month Text for AI letter
    SELECT SINGLE ltx
    FROM t247
    INTO w_ltx
    WHERE spras = sy-langu
      AND   mnr = w_mnr.

    CONCATENATE pr_date+6(2) w_ltx pr_date(4) INTO w_date separated by space.

Hope this helps u.

*****Reward points if helpful.

All the best

Former Member
0 Kudos

write like this in text editor of date window

/: SET DATE MASK = 'MMMM DD, YYYY'

Regards

Former Member
0 Kudos

Hi,

date EQ 'X'. "The date format is like Aprial 31, 2007

CONDENSE temp_date NO-GAPS.

SPLIT date AT ',' INTO daymonth year.

IF STRLEN( year ) NE '4'.

error = 'X'.

WRITE : 'Invalid date format.'.

ELSE.

daymonth1 = daymonth.

CONDENSE daymonth1 NO-GAPS.

_len = STRLEN( _daymonth1 ).

l_len = 13 - len.

SHIFT daymonth1 RIGHT BY len PLACES.

CONDENSE daymonth1 NO-GAPS.

month = daymonth1.

CONDENSE month NO-GAPS.

SORT t_month BY monthltx.

READ TABLE t_month WITH KEY monthltx = month.

IF sy-subrc <> 0.

error = 'X'.

WRITE : 'Invalid date format.' .

ELSE.

len = STRLEN( month ).

CONDENSE daymonth NO-GAPS.

SHIFT daymonth LEFT BY len PLACES.

day = daymonth.

CONDENSE day NO-GAPS.

CONCATENATE year t_month-monthnumber day INTO o_date.

ENDIF.

ENDIF.

Regards

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Try this.It will help you.

data : d1(10) value '06/20/2007',

c1(2),

c2(20).

c1 = d1+3(2).

data x_ltx type t247-ltx.

select single ltx into x_ltx from T247 where spras = 'E' and

mnr = d1+0(2).

concatenate x_ltx d13(2) ',' d16(4) into c2.

write c2.

Reward points if it helps.

Former Member
0 Kudos

sarala,

Ex: v_date = '06/20/2007'.

v_date_t(15).

DATA : v_day(2),

v_mon(2),

v_year(4).

v_month = v_date+0(2).

v_day = v_date+3(2).

v_year = v_date=6(4).

select LTX from t247 into t247-ltx

where mnr eq v_month and spras eq 'EN'.

concatenate t247-ltx v_day ',' v_year into v_date_t.

Don't forget to reward if useful...

From the given data separate the MONTH,DATE and YEAR

take the Month and get the description of month from T247 Table

then concatenate the Month description date,year into a string and use

it's simple

Former Member
0 Kudos

please copy and paste it was for you .

REPORT  ZAASD.


parameter :   ld_date  like sy-datum .


DATA  : BEGIN  OF MONTH_NAMES1  OCCURS  0 .
INCLUDE  STRUCTURE  T247 .
DATA : END OF MONTH_NAMES1 .


data :  dates(25)  type  c .

CALL FUNCTION 'MONTH_NAMES_GET'
 EXPORTING
   LANGUAGE                    = SY-LANGU
* IMPORTING
*   RETURN_CODE                 =
  TABLES
    MONTH_NAMES                 =  MONTH_NAMES1
* EXCEPTIONS
*   MONTH_NAMES_NOT_FOUND       = 1
*   OTHERS                      = 2
          .
IF SY-SUBRC = 0.
LOOP AT MONTH_NAMES1  WHERE MNR =  ld_date+4(2) .

CONCATENATE     MONTH_NAMES1-LTX ld_date+6(2)','ld_date(4)','   into  dates  .

write  : / dates .
ENDLOOP.
ENDIF.

reward points if it is usefull ...

Girish