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

How to convert string to date format?

Former Member
0 Likes
34,741

Hi All,

String is in following format: 2006-12-07 i.e yyyy-mm-dd

I want it in 07.12.2006 date format.

which function module should i used to convert it?

Regards,

Nilima

Hi All,

String is in following format: 2006-12-07 i.e yyyy-mm-dd

I want it in 07.12.2006 date format.

which function module should i used to convert it?

Regards,

Nilima

5 REPLIES 5
Read only

gopi_narendra
Active Contributor
9,814

Use the FM : CONVERSION_EXIT_IDATE_INPUT to convert date to Date format.

Regards

Gopi

Read only

Former Member
0 Likes
9,814

Hi Nilima,

lv_date = 2006-12-07

use

concatenate lv_date+8(2)

'.'

lv_date+5(2)

'.'

lv_date+0(4)

into lv_date_new

Regards

Arun

Read only

Former Member
0 Likes
9,814

Hi,

Try like this:

DATA: ZTEMP(10),zdd(3),zmmm(3),zyyyy(4),zfinal(12), v_date(10) type c.

CLEAR: ZTEMP, ZDD, ZMMM, ZYYYY.

v_date = '2007-08-07'. "yyyy-mm-dd

zyyyy = v_date+0(4).

zmmm = v_date+5(2).

zdd = v_date+8(2).

concatenate zdd '.' zmmm '.' zyyyy into ztemp.

write:/ v_date,

/ ztemp.

Regards,

Bhaskar

Read only

Former Member
0 Likes
9,814

an other way to do this :

Code

DATA :

ld_text(20) TYPE c,

ld_date TYPE datum.

ld_text = '2006-12-07'.

REPLACE ALL OCCURENCES OF '-' IN ld_text WITH ''.

WRITE ld_text TO ld_date.

WRITE ld_date.

Read only

former_member386202
Active Contributor
0 Likes
9,814

Hi,

I dont think there will be FM for this. Try Like this

data: lv_formatdate(10) type c,

         lv_date type char10.

lv_date = 2006-12-07.

  var1 = lv_date+(4).

  var2 = lv_date+5(2).

  var3 = lv_date+8(2).

concatenate var3 var2 var1 into lv_formatdate separated by '.'.

Regards,

Prashant