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 formate in WRITE statment

Former Member
0 Likes
653

Hi all,

how to change the date formate in the WRITE statement directly.

ex: write:/ p0000-begda.

i need to conver date into desired formate in the output only.

waiting for reply.

thanks

4 REPLIES 4
Read only

Former Member
0 Likes
618

See the below example program :

India Date format :

data : v_date(10) type c,

v_day(2) type c,

v_month(2) type c,

v_year(4) type c.

data : date(8) type c.

start-of-selection.

date = sy-datum.

v_year = date+0(4).

v_month = date+4(2).

v_day = date+6(2).

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

write:/ v_date.

USA date Format :

data : v_date(10) type c,

v_day(2) type c,

v_month(2) type c,

v_year(4) type c.

data : date(8) type c.

start-of-selection.

date = sy-datum.

v_year = date+0(4).

v_month = date+4(2).

v_day = date+6(2).

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

write:/ v_date.

if you need only output then use like this

WRITE: / sy-datum DD/MM/YYYY.

Reward Points if it is helpful

Thanks

Seshu

Message was edited by:

Seshu Maramreddy

Read only

uwe_schieferstein
Active Contributor
0 Likes
618

Hello Prakash

Have a look in the keyword documentation for the <b>WRITE </b>statement. To output dates in a specific format you can use the following option:

WRITE: / p0000-begda DD/MM/YYYY.  " or YYYY/MM/DD

Regards

Uwe

Read only

Former Member
0 Likes
618

Hi Prakash,

Just go to 'Formatting Options' of the WRITE statement in the ABAP documentation, and you could find a variety of ways in which dates can be formatted. These are :

1.DD/MM/YY

2.MM/DD/YY

3.DD/MM/YYYY

4MM/DD/YYYY

5.DDMMYY

6.MMDDYY

7.YYMMDD

You just need to use it the way Uwe has mentioned.

Hope this helps.

Regards

Anil Madhavan

Read only

Former Member
0 Likes
618

Hi Prakash,

Use the syntax :

WRITE p0000-begda DD/MM/YYYY.

Award points if found useful.

Regards

Indrajit