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

Former Member
0 Likes
1,655

i need to change the date format rom ddmmyyyy to yyyymmdd. i know this can be done using edit mask. but i don't know the syntax for this , could any one plz.

14 REPLIES 14
Read only

Former Member
0 Likes
1,615

hi sunil,

1. we can take another variable and using offset concept we can do that.

2. concatenate mydate4(4) mydate2(2) mydate(2)

into newdate.

Read only

0 Likes
1,615

How we can write using edit mask

Read only

Former Member
0 Likes
1,615

Hi,

In SAP all the dates are stored in the format YYYYMMDD only.

if you are getting that field from somewhere just keep as it is:

if you wants from ddmmyyyy to yyyymmdd:

data: date(8), date1(8), mon(2),day(2),year(4).

date = ddmmyyyy

year = date+4(4).

mon = date+2(2)

day = date+0(2).

concatenate year mon day into date1.

reward if useful

regards,

ANJI

Read only

Former Member
0 Likes
1,615

Hi Sunil,

Hope this code helps you.

data mydate like sy-datum.

data: year(4) type c,

month(2) type c,

date(2) type c.

year = mydate(4).

month = mydate+4(2).

date = mydate+6(2).

write: / year no-gap, month no-gap, date.

reward if helpful.

Regards,

Thasneem

Read only

Former Member
0 Likes
1,615

Hi,

You can use the below syntax for this one

concatenate mydate4(4) mydate2(2) mydate(2)

Even you can use the Function module <b>CONVERT_DATE_TO_INTERNAL</b> to convert the internal format.

Regards

Sudheer

Read only

Former Member
0 Likes
1,615

fromdate4(4) = sy-datum0(4).

fromdate+2(2) = write month.

fromdate+0(2) = write days

Read only

Former Member
0 Likes
1,615

sunil,

Here s_date is your date input field.

concatenate s_date4(4) s_date2(2) s_date+0(2) into s_date.

Don't forget to reward if useful...

Read only

Former Member
0 Likes
1,615

WRITE /(30) sy-datum USING EDIT MASK

'RRThe duration is ____/__/__'.

Here are some of available options..

... DD/MM/YY | MM/DD/YY

| DD/MM/YYYY | MM/DD/YYYY

| DDMMYY | MMDDYY | YYMMDD

Reward if helpful...

Read only

Former Member
0 Likes
1,615

Hi Sunil,

Check with this please...

data : m like sy-datum..

write sy-datum to m using edit mask '__ __ __'.

write m.

Hope this helps you, reply for queries, Shall post you the updates.

Regards.

Kumar

Read only

anversha_s
Active Contributor
0 Likes
1,615

hi,

chk this.

data : v_date1(10) value '23/02/2007',
         v_date(8).
 
concatenate  v_date1+6(4) v_date1+3(2) v_date1+0(2) into v_date.


OR 


data : v_date1 TYPE KCDE_INTERN_VALUE,
v_date2 TYPE KCDE_INTERN_VALUE.

CALL FUNCTION 'KCD_EXCEL_DATE_CONVERT'
EXPORTING
EXCEL_DATE = v_date1
DATE_FORMAT = 'TMJ'
IMPORTING
SAP_DATE = v_date2
EXCEPTIONS
OTHERS = 0.

Regds

Anversha

Read only

former_member673464
Active Contributor
0 Likes
1,615

hi,

Dont have any edit mask to write in format yyyymmdd.But we have format yymmdd Here is syntax for that edit mask.

WRITE: sy-datum, / sy-datum yymmdd.

regards,

veeresh

Read only

0 Likes
1,615

Hi

But the complete year is not coming, as its coming 07 but i need 2007

Read only

0 Likes
1,615

Hi..,

u can write it as ..

sorry..

try this.. its working..

<b>WRITE: sy-datum, / sy-datum using edit mask '____.__.__'.</b>

or use this .. to eliminate the separators also..

<b>WRITE: sy-datum, / sy-datum using edit mask '________'.</b>

reward all helpful answers ..

sai ramesh

Read only

Former Member
0 Likes
1,615

Hi Sunil,

Check this info.

Use function module CONVERT_DATE_TO_EXTERNAL. This will convert the date to the user specific format. So if your user specific format is mm/dd/yyyy, then this is all you need.

Hope this resolves your query.

Reward all the helpful answers.

Regards