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 conversion

Former Member
0 Likes
666

1)To convert the date from 08/01/2008 to 2008/08/01 I used the following code.But I am getting 20/08/0801.Can anybody suggest the best method for this? If possible send the code also.

va_datum = sy-datum.

concatenate va_datum4(4) va_datum0(2) va_datum+2(2) into va_date .

Thanks in advance.

Raghu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
642

Hi,

DATA:

va_date(10),

va_datum LIKE sy-datum.

va_datum = sy-datum.

MOVE:

va_datum0(4) TO va_date0(4),

'/' TO va_date+4(1),

va_datum4(2) TO va_date5(2),

'/' TO va_date+7(1),

va_datum6(2) TO va_date8(2).

Thanks,

Veera K

5 REPLIES 5
Read only

Former Member
0 Likes
642
va_datum = sy-datum.
concatenate va_datum+6(4) '/' va_datum+0(2) '/'  va_datum+3(2) into va_date .
Read only

Former Member
0 Likes
642

data dt type sy-datum.

dt = sy-datum.

data str type string.

str = dt.

concatenate dt0(4) '/' dt4(2) '/' dt+6(2) into str.

write 😕 str.

Read only

Former Member
0 Likes
643

Hi,

DATA:

va_date(10),

va_datum LIKE sy-datum.

va_datum = sy-datum.

MOVE:

va_datum0(4) TO va_date0(4),

'/' TO va_date+4(1),

va_datum4(2) TO va_date5(2),

'/' TO va_date+7(1),

va_datum6(2) TO va_date8(2).

Thanks,

Veera K

Read only

former_member217544
Active Contributor
0 Likes
642

Hi,

If va_datum contnais value in this format 08012008 then use

concatenate va_datum+4(4)

va_datum+0(2)

va_datum+2(2)

into va_date .

if va_datum contanis value in this format 08/01/2008 the use this logic

concatenate va_datum+6(4)

va_datum+0(2)

va_datum+3(2)

into va_date

separated by ' / ' .

Hope this will help.

Regards,

Swarna Munukoti.

Edited by: Swarna Munukoti on Aug 1, 2008 10:24 AM

Read only

Former Member
0 Likes
642

Hi,

Check the following code:

data: va_datum like sy-datum.

data: v_year(4) type c,

v_month(2) type c,

v_day(2) type c,

v_final(10) type c.

va_datum = sy-datum.

v_year = va_datum+0(4).

v_month = va_datum+2(2).

v_day = va_datum+6(2).

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

write : / va_datum,

/ v_final.

Regards,

Bhaskar