Application Development and Automation 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: 
Read only

Date Conversion ?

Former Member
0 Likes
908

Hi All,

I want to convert date format '20070505' to 05-May-07. Is there any FM to achieve this ?

regards,

Navneeth K.

6 REPLIES 6
Read only

Former Member
0 Likes
871

Hi Navaneeth,

Use the command

SET DATE MASK 'DD-MMM-YY'.

and see

Regards

Anji

Read only

Former Member
0 Likes
871

Hi,

BKK_DATE_STRING_CONVERT

Hope this will be helpful to u.

Thanks,

Deepti

Read only

Former Member
0 Likes
871

Here is the samle code for it ..

DATA: ZTEMP(9).  

CLEAR: ZTEMP, ZDD, ZMMM, ZYYYY.  

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'  
EXPORTING  
INPUT = IS_DLV_DELNOTE-HD_GEN-CREA_DATE  
IMPORTING  
OUTPUT = ZTEMP.  

ZDD = ZTEMP+3(2).  
ZMMM = ZTEMP+0(3).  
ZYYYY = ZTEMP+5(4). 

<b>This code yields as 12 march 2006.</b>

reward points if it is usefull ...

Girish

Read only

Former Member
0 Likes
871
REPORT ychatest MESSAGE-ID zz..

TABLES : t247.

DATA : v_ktx LIKE t247-ktx,
       v_date LIKE sy-datum VALUE '20070618',
       v_final(9).

SELECT SINGLE ktx INTO v_ktx FROM t247 WHERE mnr EQ v_date+4(2).
TRANSLATE v_ktx TO UPPER CASE.
CONCATENATE v_date+6(2) v_ktx v_date+2(2) INTO v_final SEPARATED BY '-'.

WRITE : v_final.
Read only

abdul_hakim
Active Contributor
0 Likes
871

Hi,

Create your own function module..

Put this source code in your function module..

*"----


""Local interface:

*" IMPORTING

*" VALUE(IM_DATE) TYPE SYDATUM

*" EXPORTING

*" REFERENCE(EX_DATE_TXT) TYPE STRING

*" EXCEPTIONS

*" IF_NULL

*"----


======================================================================

  • Processing Logic

======================================================================

  • If the date is blank, raise a NULL exception

IF IM_DATE IS INITIAL.

RAISE IF_NULL.

ENDIF.

v_yr = IM_DATE(4) . " TO READ THE FIRST 4 CHARS AS YEAR

v_mon = IM_DATE+4(2) . " TO READ THE 5TH & 6TH CHAR AS MONTH

v_dt = IM_DATE+6(2) . " TO READ THE LAST 2 CHARS AS DAY

  • Get the month name

SELECT SINGLE MONAM FROM T015M

INTO v_month

WHERE spras = sy-langu

AND monum = v_mon.

  • To format the specific date in words

CONCATENATE v_DT TEXT-013 INTO v_CON SEPARATED BY SPACE.

CONCATENATE v_CON v_MONTH TEXT-013 v_YR INTO v_DATE1 SEPARATED BY SPACE.

EX_DATE_TXT = v_DATE1.

CLEAR:v_yr,v_mon,v_dt,v_month,v_con,v_date1.

I have used the above code in my program and it is working fine for me..

Test Cases:

INPUT: 18.06.2007

OUTPUT: 18 of June of 2007

Cheers,

Hakim

mark all useful answers..

Read only

Former Member
0 Likes
871

Hi try this. it will work

data : v_date(12) type c.

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'

EXPORTING

INPUT = p_date

IMPORTING

OUTPUT = v_date.

p_date = 20070505

v_date = 05MAY2007