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

How to convert DATE variable to CHAR variable

Former Member
0 Likes
7,682

dear all,

How to convert DATE variable to CHAR variable

thanq

6 REPLIES 6
Read only

Former Member
0 Likes
2,836

s_date type sy-datum.

c_date(10) like character.

s_date = c_date.

Read only

Former Member
0 Likes
2,836

data : v_date(10).

write sy-datum to v_date.

Read only

Former Member
0 Likes
2,836

Depending on your final goal here are 2 options.


DATA: datein        TYPE d.
DATA: dateout(10)   TYPE c.
DATA: dateout2(8)   TYPE c.

datein = sy-datum.
WRITE datein TO dateout MM/DD/YYYY.
dateout2 = datein.
WRITE:/ datein, dateout, dateout2.

and the output


05022008 05/02/2008 20080502     

Read only

Former Member
0 Likes
2,836

try this code:

data : v_date like sy-datum,

v_char(8) type c.

v_char = v_date.

Regards,

Dara.

Read only

asik_shameem
Active Contributor
0 Likes
2,836

Hi

Do in this way.

DATA: gv_date TYPE sy-datum '20080501'.

DATA: gv_date_c(10) TYPE c.

CONCATENATE gv_date6+(2) gv_date+4(2) gv_date(4) INTO gv_date_c  SEPARATED BY '.'.

WRITE: gv_date_c

Read only

Former Member
0 Likes
2,836

data: v_Date type sy-datum,

v_char(10) type c.

v_date = sy-datum.

v_char = v_date.

concatenate v_char6(2) v_char4(2) v_char+0(4) into v_char separated by '.'.

write: / v_char.