Application Development 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: 

change format of date

Former Member
0 Kudos
68

hi

i have field with date and i wont to change format i give example.

data: date1 type d,

date2 type char7.

date1 = 20070517

date2 = 05.2007

how i change the format of date1 to date2?

Regards

1 ACCEPTED SOLUTION

ferry_lianto
Active Contributor
0 Kudos
48

Hi,

Please try this.


data: date1    type sy-datum,
      date2(7) type c.

move:  date1+4(2) to date2(2),
       '.'        to date2+2(1),
       date1(4)   to date2+3(4).

write: date2.

Regards,

Ferry Lianto

3 REPLIES 3

Former Member
0 Kudos
48

Hi,

Do like this

data: date1 type sy-datum,
date2(7) type c.

date1 = 20070517

concatenate date1+4(2) date1+0(4) into date2 seperated by '.'.

Write Date2.

Regards,

Satish

naimesh_patel
Active Contributor
0 Kudos
48

You can try like this also:

REPORT  ztest_np_test.

DATA: l_date TYPE d,
      l_char(10).

l_date = sy-datum.
WRITE l_date TO l_char DD/MM/YYYY.
l_char = l_char+3.
TRANSLATE l_char USING '/.'.
WRITE: l_char.

Regards,

Naimesh Patel

ferry_lianto
Active Contributor
0 Kudos
49

Hi,

Please try this.


data: date1    type sy-datum,
      date2(7) type c.

move:  date1+4(2) to date2(2),
       '.'        to date2+2(1),
       date1(4)   to date2+3(4).

write: date2.

Regards,

Ferry Lianto