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

date format change

Former Member
0 Likes
1,391

i am reading date from text file in the fromat(yyyymmdd) 20061128, i want to change this format to 28.11.2006 how can i do this.

regards

martin

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,342

data: g_date(10) type c.

concatenate date6(2) '.' date4(2) '.' date+0(4) into g_date.

12 REPLIES 12
Read only

Former Member
0 Likes
1,342

Please check FM

<b>CONVERSION_EXIT_PDATE_OUTPUT</b>

Also make sure that your user setting default is DD.MM.YYYY. You can do this by going to transaction SU01 give your user name and under the tab Default ,make sure your user format is DD.MM.YYYY

Message was edited by:

Dominic Pappaly

Read only

Former Member
0 Likes
1,342

using wrtie statement u can change

WRITE sy-datum TO l_string1 USING EDIT MASK '__-__-____'.

Read only

0 Likes
1,342

i dont want to write this value, i am passing this value using BDC using work area, how can i change this value before passing.

Read only

0 Likes
1,342

Hi Martin,

Write Sy-datum to l_date

this statement won't display.

just it converts the to default format of the use settings.(own data)

If you want to see the output

the Sample Code follows

data : l_string1(10) type c.

WRITE sy-datum TO l_string1 .

write : / l_string1.

Thanks

Sekhar.

Read only

0 Likes
1,342

Hi Martin,

If you are using this date value in the BDC then you need to convert this as per the user settings. not in the specific format DD.MM.YYYY, because if this program will be exectued by the different users. Their user setting may not be DD.MM.YYYY.

So, try like this...

DATA: lv_date like sy-datum,

write file-date to lv_date.

Here the date will be wirtten to lv_date based on the user setting. You can check this while changing your user setting in tcode SU01.

Hope this will slove you problem.

Regards,

Satya.

Read only

Former Member
0 Likes
1,343

data: g_date(10) type c.

concatenate date6(2) '.' date4(2) '.' date+0(4) into g_date.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,342

Hi,

For BDC,you need to pass it as character.

data v1(10).

v2 = '20061128'.

concatenate v26(2)'.' v24(2) '.' v2+0(4) into v1.

Read only

anversha_s
Active Contributor
0 Likes
1,342

hi,

please try this.

data:lcdate(11).
 
call function 'converstion_exit_idate_output'
exporting
input = sy-datum
importing
output = lcdate.
 
concatenate lcdate(2) lcdate+2(3) lcdate+5(4) into lcdate seperated by '.'.

--lcdate is your required format.

sample data ..sy-datum = 20060830

lcdate = 30.AUG.2006

so if u dont want 'AUG', just put that months number there.

Regards,

Anver

<b><i>

if hlped pls mark points</i></b>

Read only

Former Member
0 Likes
1,342

First check whether in the user settings the date format is ddmmyyyy then you can use simply write to statement other wise you just off set the date format like

if lv_date has date in 20061128

then use concatenate lv_date6(2) '.' lv_date4(2) '.' lv_date+0(4) to lv_date1.

this will give the format 28.11.2006 .

Br,

Ravi

Read only

0 Likes
1,342

when i am using contatenate for 20061128 then it will result in 28.11.20

the last 06 is not comming , what can i do...

Read only

0 Likes
1,342

hi,

increase the size.

make it to char10.

rgds

Anver

Read only

Former Member
0 Likes
1,342

hi,

PARAMETERS: P_DATE LIKE SY-DATUM.

DATA: T_MONTHS LIKE STANDARD TABLE OF T247 WITH HEADER LINE.

DATA: DATE LIKE AUSP-ATWRT.

CALL FUNCTION 'MONTH_NAMES_GET'

TABLES

MONTH_NAMES = T_MONTHS.

READ TABLE T_MONTHS WITH KEY MNR = P_DATE+4(2).

DATE(2) = P_DATE+6(2).

DATE+2(3) = T_MONTHS-KTX.

DATE5(2) = P_DATE2(2).

WRITE DATE.

or

Date = YYYYMMDD

Concatenate date4(2) ‘ /’ date6(2) ‘/’ date(4) into Date2.

or

data : l_date(10) type c .

concatenate sy-datum6(2) '/' sy-datum4(2) '/' sy-datum(4) into l_date.

write : l_date.

or

data :l_date(10) type c

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

DATE_INTERNAL = SY-DATUM

IMPORTING

DATE_EXTERNAL = l_date.

Regards,

Laxmi.