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

String to date type conversion

Former Member
0 Likes
7,315

Hi,

How to convert string "20080704" to date format?

Regards,

Asha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,046

Hi,

Check this sample code,

DATA:
  w_date1   TYPE sy-datum,
  w_date    TYPE string VALUE '20080730'.

w_date1 = w_date  .
WRITE: w_date1.

Regards

Adil

12 REPLIES 12
Read only

Former Member
0 Likes
3,046

use edit mask or offset values..

data: v_data type string ,

data(10) type c .

v_data = '20080101'.

data = v_data .

write:/ data using edit mask '____/__/__'.

Read only

Former Member
0 Likes
3,046

Hi

Go through the link given below :

With Regards

Nikunj shah

Read only

Former Member
0 Likes
3,046

Hi,

1.Take a variable of type sy-datum

2. Assign your string to the variable.

Data:
  date type sy-datum.

...........
...........

date = string.

Regards,

anirban

Read only

Former Member
0 Likes
3,047

Hi,

Check this sample code,

DATA:
  w_date1   TYPE sy-datum,
  w_date    TYPE string VALUE '20080730'.

w_date1 = w_date  .
WRITE: w_date1.

Regards

Adil

Read only

0 Likes
3,046

Thanks a lot,

it solved my issue

Read only

Former Member
0 Likes
3,046

Use edit mask ..

data : v_d1(10) value '20080704'.

write 😕 v_d1 using edit mask '____/__/__'.

Read only

Former Member
0 Likes
3,046

hi,

Assign that value to a field of type sy-datum.

eg.

Date = sy-datum.

Date = '20080704'.

Regards

Sumit Agarwal

Read only

Former Member
0 Likes
3,046

Hi Asha,

Try this code below :

data :
  w_string type string value '20080704',
  w_date type sy-datum.

w_date+0(4) = w_string+0(4).  " Year
w_date+4(2) = w_string+4(2).  " Month
w_date+6(2) = w_string+6(2).  " Day

write : / w_date.

Regards,

Swapna.

Read only

Former Member
0 Likes
3,046

hi

use this FM

HRGPBS_HESA_DATE_FORMAT : Format the date in dd/mm/yyyy format

Cheers

Snehi

Read only

former_member787646
Contributor
0 Likes
3,046

Hi

Use the Function Module "CONVERSION_EXIT_ALPHA_INPUT"

Hope it helps.

Murthy

Read only

Former Member
0 Likes
3,046

Hi Asha,

Just check this ... i hope this will solve ur problem..

data:date1 like sy-datum.

data:months type i,

days type i,

r_date(10) type c.

date1 = '20081015'.

months = date1+4(2).

days = date1+6(2).

CALL FUNCTION 'CALCULATE_DATE'

EXPORTING

DAYS = DAYS

MONTHS = MONTHS

START_DATE = SY-DATUM

IMPORTING

RESULT_DATE = r_date.

write:r_date.

Thanks & Regards

Ashu Singh

.

Read only

Former Member
0 Likes
3,046

Hi Asha.

I would like to suggest a few references,

[SDN - Reference for Conversion of String to Date format|;

[SDN - Reference for formating string to date format|;

[SDN - Reference - Problem with Userdefined Date Format function|]

[SDN - Reference for Date data type conversion into String data type|;

Hope that's usefull.

Good Luck & Regards.

Harsh Dave