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

Convert Date Format

Former Member
0 Likes
598

Hi Experts,

Is there a FM to convert a Date from format YYYYMMDD to MM/DD/YYYY.

For eg: I wanna see 20070604 as 06/04/2007. Please advise.

Thanks a lot for your help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
565

No need to use function module.

data date_char(10).

write sy-datum to date_char.

DATE_CHAR will have value in mm/dd/yyyy.

And if you wanna display the date then directly:

write sy-datum.

The date displayed in output will be in mm/dd/yyyy format.

In your example:

data date_char(10).

data date_date type d.

date_date = '20070604'.

write date_date to date_char.

date_char will have value '06/04/2007'.

4 REPLIES 4
Read only

Former Member
0 Likes
566

No need to use function module.

data date_char(10).

write sy-datum to date_char.

DATE_CHAR will have value in mm/dd/yyyy.

And if you wanna display the date then directly:

write sy-datum.

The date displayed in output will be in mm/dd/yyyy format.

In your example:

data date_char(10).

data date_date type d.

date_date = '20070604'.

write date_date to date_char.

date_char will have value '06/04/2007'.

Read only

0 Likes
565

Great! Thanks for the help. But I have two dates to display in the output. How can I do that in this case?

Thanks.

Read only

Former Member
0 Likes
565

data : v_date(10) type c,

v_day(2) type c,

v_mon(2) type c,

v_year(4) type c.

data v_mdate(8) type c.

start-of-selection.

v_mdate = sy-datum.

v_year = v_mdate+0(4).

v_mon = v_mdate+4(2).

v_day = v_mdate+6(2).

concatenate v_mon '/' v_day '/' v_year into v_date.

write v_date.

Read only

0 Likes
565

Thanks all