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

formatting date

Former Member
0 Likes
974

I have a date dd.mm.yyyy

I need to convert it to 6 digits and display it

should i use format_date(6) type i ?

how do i do the conversion

1 ACCEPTED SOLUTION
Read only

ferry_lianto
Active Contributor
0 Likes
952

Hi,

You need to use offset and store the final result to your variable.


data: v_date(6) type c.
 
v_date+0(2) = sy-datum+4(2).
v_date+2(2) = sy-datum+6(2).
v_date+4(2) = sy-datum+2(2).
 
write: / v_date.
 
move v_date to  ...

or 

write: / sy-datum MMDDYY to v_date.

Any update on this issue?

Regards,

Ferry Lianto

10 REPLIES 10
Read only

Former Member
0 Likes
952

hi,

Use offset for that

data : v_date type sy-datum value '20070101'.

 v_date = v_date+0(6).

write v_date.

Regards,

Santosh

Read only

Former Member
0 Likes
952

need to display it as mmddyy

Read only

Former Member
0 Likes
952
data : v_date(10) value '21.03.2007',
         v_date1(6),
         v_int type i.

concatenate v_date+3(2) v_date+0(2) v_date+8(2) into v_date1.

v_int = v_date1.

write : v_int.

Message was edited by:

Chandrasekhar Jagarlamudi

Read only

Former Member
0 Likes
952

isnt there some built in function that i can use

so regardless of the format of the input date, my output is mmddyy

Read only

ferry_lianto
Active Contributor
0 Likes
952

Hi,

Please try this.


data: v_date(6) type c.

v_date+0(2) = sy-datum+4(2).
v_date+2(2) = sy-datum+6(2).
v_date+4(2) = sy-datum+2(2).

write: / v_date.

or 

write: / sy-datum MMDDYY.

Read only

Former Member
0 Likes
952

then do this way ..

data : v_date(10) type c value '10.10.2007 '.
 
concatenate v_date+0(2) v_date+3(2) v_date+8(2) into v_date  
 
write v_date.

Read only

Former Member
0 Likes
952
data: v_date(6) type c.
v_date+0(2) = sy-datum+4(2).
v_date+2(2) = sy-datum+6(2).
v_date+4(2) = sy-datum+2(2).
write: / v_date.
or 
write: / sy-datum MMDDYY.

I am looking for something like the last write statement

But I need to be able to save it in a variable

Read only

0 Likes
952

Hi ,

you can use get it into a variable with the following statement

write sy-datum MMDDYY to v_date.

if current date is 03/21/2007

the value in v_date will be 030207.

-Kalyan

Read only

0 Likes
952

This is all you need to do.


DATA: v_date(6).

WRITE sy-datum TO v_date.

WRITE: v_date.

This will write the date into v_date based on the user profile.

Read only

ferry_lianto
Active Contributor
0 Likes
953

Hi,

You need to use offset and store the final result to your variable.


data: v_date(6) type c.
 
v_date+0(2) = sy-datum+4(2).
v_date+2(2) = sy-datum+6(2).
v_date+4(2) = sy-datum+2(2).
 
write: / v_date.
 
move v_date to  ...

or 

write: / sy-datum MMDDYY to v_date.

Any update on this issue?

Regards,

Ferry Lianto