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: 

Date conversion

Former Member
0 Kudos

I have the date in 'yyyy/mm/dd' format but I want the date in 'mm/dd/yy' format and to be stored in the variable in this format. Is there is any function module or code that enable me to do it.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Santhosh,

Try the write statement:

WRITE: f to g DD/MM/YY.

This should work fine.

Brad

7 REPLIES 7

Former Member
0 Kudos

Hi Santhosh,

Try the write statement:

WRITE: f to g DD/MM/YY.

This should work fine.

Brad

0 Kudos

Thanks. I think you can help me out here.I know that it works with the write statement but I need to store the date in this form in a variable and concatenate it with other variables and then use the write statement.

0 Kudos

Hi Santhosh,

You can do something like:


DATA: w_date              type d value '20050512',
      w_char_date(8)      type c,
      w_other_string(100) type c,

WRITE: w_date to w_char_date DD/MM/YY.

CONCATENATE 'Other text' w_char_date into w_other_string.

WRITE: w_other_string.

That should do it.

Brad

Message was edited by: Brad Williams

0 Kudos

Thank you Brad!!! I got it.It really helped.Just alittle more help would be just great. Now I have got 'Todate'by using sy-datum in the format 'mm/dd/yy' and I have to set the 'fromdate' i.e to the firstday of the month(just need to change the date part. i tried the OFFSET command and set it to '01' I am not getting it. if you could help me that would just great.

Thanks

Santhosh

0 Kudos

So,

Try manipulating the string:


DATA: w_date              type d value sy-datum,
      w_from_date(8)      type c,
      w_to_date(8)        type c,
      w_other_string(100) type c,
 
WRITE: w_date to w_to_date DD/MM/YY.
w_from_date = w_to_date.
w_from_date+0(2) = '01'.
 
CONCATENATE w_from_date ' to ' w_to_date into w_other_string.
 
WRITE: w_other_string.

That should be fine.

Please remember to award points to posts that have been useful to you.

Brad

0 Kudos

Thanks a lot Brad,It really solved my problem. I have awarded points for your help. Have a great week end.

Santhosh

christian_wohlfahrt
Active Contributor
0 Kudos

How about using at first write and at second step concatenate?