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 converting

Former Member
0 Likes
913

Hi All,

How to convert the date 20080523 into 05/23/2008. pls provide me the code.

Regards

Sami

7 REPLIES 7
Read only

Former Member
0 Likes
892

Hi,

data: v_date type sy-datum value '20080523'.

data: v_result(10).

concatenate v_date4(2) v_date6(2) v_date+0(4) into v_result separated by '/'.

write:/ v_result.

Edited by: Velangini Showry Maria Kumar Bandanadham on May 23, 2008 2:52 PM

Read only

Former Member
0 Likes
892

Hi,

You can use this function module:

CONVERT_DATE_TO_EXTERNAL

in import the variable should be of char type.

Read only

Former Member
0 Likes
892

Hi,

Check the code below:

data: v_var1(10) type c,
        v_var2 type sy-datum.

v_var2 = sy-datum.

CONCATENATE v_var2+4(2) '/' v_var2+6(2) '/' v_var2+0(4) INTO v_var1.

Regards

Kannaiah

Read only

former_member125661
Contributor
0 Likes
892

Use write Statment:

data : date(10).

write sy-datum to date mm/dd/yyyy. " writes 20080924 as 09/24/2008 in date.

Read only

0 Likes
892

Also need add some code for this:

DATA: X TYPE D VALUE '20080523',
      Y(10) .

WRITE X MM/DD/YYYY TO Y.
REPLACE ALL OCCURRENCES OF '.' IN Y WITH '/'.
WRITE Y.

Read only

Former Member
0 Likes
892

Hello,

Use this:


WRITE sy-datum TO lv_variable MM/DD/YYYY. 

The content of a data object of type d is interpreted as a valid date in the format YYYYMMDD and is output as follows for the individual additions:

DD/MM/YY and MM/DD/YY:

Both additions have the same effect. The date output has a two-digit year value and a separator. The separator and the order are taken from the definition for date output in the user master record.

DD/MM/YYYY und MM/DD/YYYY:

Both additions have the same effect. The date output has a four-digit year value and separator. The separator and the order are taken from the definition for date output in the user master record.

DDMMYY und MMDDYY:

Both additions have the same effect. The date output has a two-digit year value and no separator. The order is taken from the definition for date output in the user master record.

YYMMDD:

This addition provides a date output with a two-digit year value without a separator in the format YYMMDD.

If the output length is defined implicitly or specified using len, this is used. If it is too short, the edited output is cut off to the right. If the output length is specified using * or **, it is set to the length of the specified edit mask (6, 8, or 10).

Note

The behavior for abbreviation differs from the output of a data in accordance with the user master record, where the separator is removed first and then cut off.

Regards,

Read only

Former Member
0 Likes
892

Hi, Check this out.

data: date1 type sy-datum value '20080523'.

data:result(10).

concatenate date14(2) date16(2) date1+0(4) into result separated by '/'.

reward me if it helps.

Kinjal