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

Format date

Former Member
0 Likes
834

I am gathering date as yymmdd

How do I format this date to sy-datum format yyyymmdd and the store it into a variable.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
810

v_dat(6) type c

v_datum like sy-datum

v_datum = yyyymmdd of v_dat

thats what i need to do

7 REPLIES 7
Read only

Former Member
0 Likes
810

hi,

do this way ..

data : v_datum like sy-datum value sy-datum.

 concatenate v_datum+0(4) v_datum+4(2) v_datum+6(2)  into v_date.

write : v_date.

Regards,

Santosh

Read only

Former Member
0 Likes
811

v_dat(6) type c

v_datum like sy-datum

v_datum = yyyymmdd of v_dat

thats what i need to do

Read only

0 Likes
810

If I understood ur requirement correctly, the code below should work

data:

v_dat(6),

v_date(10).

v_dat = '070413'.

concatenate '20' v_dat(2) v_dat2(2) v_dat+4(2) into v_date.

write:v_date.

<b>Note</b>:i've <b>hard coded</b> the value '20', change that according to ur requirement

Read only

0 Likes
810

Hi Megan,

Simple code:

data : v_dat(6) type c value '070413',

v_datum like sy-datum.

concatenate '20' v_dat0(2) v_dat2(2) v_dat+4(2) into v_datum.

write v_datum.

Hope this helps.

Thanks,

Srinivasa

Read only

Former Member
0 Likes
810
concatenate '20' v_dat+(2) v_dat+2(2) v_dat+4(2) into v_date.

What does 20 stand for here ?

Read only

0 Likes
810

Hi Megan,

20 stands for the first characters of the year.

This year is 2007 know, so 20 is the first two characters in the year.

So, when 20 is concatenating with 07, it becomes 2007 which is the current year.

Thanks,

Srinivasa

Read only

0 Likes
810

'20' stands for the first 2 characters of the century, i.e., '20'07, if the date is in 20th century then u've to use '19'...