Application Development 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: 

Problem with date format

Former Member
0 Kudos
343

the issues is that while entering in the screen, the data is in the format

mm/dd/yyyy

and when it gets displayed it changes to

yyyymmdd.

I want the same format as i am giving on the screen.

mm/dd/yyyy.

please help.

13 REPLIES 13

jayanthi_jayaraman
Active Contributor
0 Kudos
223

Hi,

Use editmask.

0 Kudos
223

How to use it ?? Can u pls give me an example

0 Kudos
223

Here is the example for EDIT MASK

Formatted output of the DATE:

DATA DATE LIKE ....

WRITE (10) DATE USING EDIT MASK '__/__/____'.

Kindly reward points and close the thread if ur problem got solned.

Message was edited by: Judith Jessie Selvi

Former Member
0 Kudos
223

Hi,

U can change before Outputing.

Just try this

DATA: lv_date LIKE datewhich u want.
IF date = 20040318
<b>CONCATENATE date+4(2) '/' date+6(2) '/' date+0(4) into lv_date.</b>

If u want to change the value in the loop then

LOOP at i_output into w_output.
CONCATENATE date+4(2) '/' date+6(2) '/' date+0(4) into w_output-date .
Modify w_output into i_output.
ENDLOOP.

It will solve ur probelm.

Hope it helps.

0 Kudos
223

Try this :

WRITE w_date TO w_date_formatted MM/DD/YYYY.

Hope this helps,

Erwan.

Former Member
0 Kudos
223

Hi,

write sy-datum MM/DD/YY .

Svetlin

andreas_mann3
Active Contributor
0 Kudos
223

Hi,

use : write to (F1)

write sy-datum to hdate.

Andreas

Former Member
0 Kudos
223

Hi,

Take a look on this one:

http://cma.zdnet.com/book/abap/ch14/ch14.htm#UsingEditMasks

Regards,

Ville

Former Member
0 Kudos
223

Hi,

Use the FM: CONVERT_DATE_TO_EXTERNAL to change 20050805

to 05.08.2005 format.

WRITE SY-DATUM TO TEMP USING EDIT MASK "__/__/____"

Specify ur required format in the double codes

Regards,

Anjali

Former Member
0 Kudos
223

svetlin answers is correct u can try for that i dont know ther remaining user answers.

Former Member
0 Kudos
223

Hi,

Well, In case if input ( i guess you are talking about selection screen input ) is coming as mm/dd/yyyy then output shopuld also come as mm/dd/yyyy without any special formatting as it is handled in user setting.

Are you assigning the date to another variable using '='. like date1 = date. and write date1.

In that case try to use WRITE DATE TO DATE1. Instead of directly assigning the date to var.

WRITE DATE1.

ex :

REPORT test.

Data :

date1(10),

date2(10).

parameters : date like sy-datum.

date1 = date.

write date to date2.

write date1.

write date.

write date2.

In above example if i/p date = 08/05/2005

date1 will be written as 20050805

and date as 08/05/2005

and date2 as 08/05/2005

regards,

Gagan

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
223

Seems like everyone has given you a valid answer. But what really is the question. How are you entering your data, in what kind of screen, selection-screen or dynpro. How are you displaying this date, selection-screen or dynpro. How is your field typed, TYPE SY-DATUM? Need more infomation to give you an answer.

Regards,

Rich Heilman

0 Kudos
223

For example, take the following program. Notice that the first date field is of type sy-datum which has conversion routine against it. Inside the program it is really in YYYYMMDD format. If you would move this data from that field into a character 10 field, the data in that field would be YYYYMMDD. If you change the P_DAT field to be of TYPE SY-DATUM. Then the conversion routine is in effect and hence will be displayed as MM/DD/YYYY.

report zrich_0002 .


parameters: p_datum type sy-datum,
           p_dat(10) type c.


at selection-screen output.

  p_dat = p_datum.

So lets say that this is your problem, I would suggest to take advantage of the conversion routine provide when using the TYPE sy-datum.

Regards,

Rich Heilman