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

Formating Date

Former Member
0 Likes
1,009

Hi,

I had character variable which gets date from the system field SY-DATUM. I am using this variable to insert into a mail body. But when I insert into a mail body it is displaying as '20060722'. But I want it in MM/DD/YYYY format. How can I format it? Please help me out.

Thanking you in advance.

Regards,

Eswar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
976

Hi eswar,

1. define a character variable of 10 length

2. use like this

3. write sy-datum to myvar.

(it will write date in the proper format

in side the variable myvar.)

4. now use this MYVAR variable.

regards,

amit m.

7 REPLIES 7
Read only

Former Member
0 Likes
977

Hi eswar,

1. define a character variable of 10 length

2. use like this

3. write sy-datum to myvar.

(it will write date in the proper format

in side the variable myvar.)

4. now use this MYVAR variable.

regards,

amit m.

Read only

Former Member
0 Likes
976

hi,

do manually.

data: str(12).

concatenate sy-datum(4)

'/' sy-datum+4(2)

'/' sy-datum+6(2) into str.

and put str into your string email body.

<u><b>addition:</b></u> or using function

CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'

EXPORTING

INPUT = sy-datum

IMPORTING

OUTPUT = str.

regards,

sandi

Message was edited by: Sandi Wijaya

Read only

Former Member
0 Likes
976

Hi Eswar,

Use Offset to Split the Date into Year Month and Date in seperate Variable and then you can Concatenate into the Target Variable as you require.

MM/DD/YYYY or DD/MM/YYYY etc.,

Hope this might help you.

Cheers,

Prashanth

Read only

naimesh_patel
Active Contributor
0 Likes
976

Hello,

Whenever you pass the value from the sy-datum to 10 char field do like this,

data: l_date(10).

write : sy-datum to l_date dd/mm/yyyy.

regards,

Naimesh

Read only

0 Likes
976

<b>1)

HRGPBS_HESA_DATE_FORMAT</b>

Format a date valid for HESA: DD/MM/YYYY

data:date_form type CHAR10.

call function 'HRGPBS_HESA_DATE_FORMAT'

exporting

P_DATE = sy-datum

importing

DATESTRING = date_form

exceptions

others = 1.

write : date_form.

<b>2)</b>Say suppose your date is date1(of the format yyyyymmdd) and date2(of the format mm/dd/yyyy)

declare variables w_year(4) type c

w_month(2) type c

w_date(2) type c

date2(10) type c.

w_year = date1+1(4).

w_month = date1+4(2).

w_date = date1+6(2).

concatenate w_month w_date w_year into w_date2 separated by '/'.

Read only

Former Member
0 Likes
976

Hi Eswar,

Please try this :-


<b>
*Declare a variable of type C and length 10.</b>
DATA  : v_date(10) TYPE c.
<b>
*Write the system date to it using  add. 'MM/DD/YYYY'</b>
WRITE sy-datum TO v_date MM/DD/YYYY.
WRITE v_date.

Hope this helps you.

Regards,

Anirban.

Read only

Former Member
0 Likes
976

Hi,

Use this Function Module!!!

CONVERT_DATE_TO_EXTERNAL

Hope this helps u.

Regards,

Seema.