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: 

convert date format dd.mm.yyyy to dd-mm-yyyy

Former Member
0 Kudos

Hi,

Is There any function module to covert date format.

I have tried an abap logic

when i am trying to download the report to excel  the date format should be change

The date 10-01-2012 in this case it is coming  perfect

This date 1-01-2012 in this case when i am downloading into excel it will come like this 1/1/2012

please give me some suggestions.

Best Regards,

Sankar.

5 REPLIES 5

iftah_peretz
Active Contributor
0 Kudos

Hi,

Here is a code to do the conversion:

DATA: days(2) type c,

      months(2) type c,

      years(4) type c.



data date type string VALUE '1-01-2012'.

SPLIT date at '-' INTO days months years.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

  EXPORTING

    INPUT         = days

IMPORTING

   OUTPUT        = days.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

  EXPORTING

    INPUT         = months

IMPORTING

   OUTPUT        = months.

CONCATENATE days months years INTO date SEPARATED BY '-'.

you can loop over the data and do this conversion and your done.

Best,

Iftah

amy_king
Active Contributor
0 Kudos

Hi Sankar,

It sounds like it is Excel that is reformatting the date string. Try wrapping your date string in double quotes before passing to Excel, e.g., instead of passing the string 1-01-2012 to Excel, pass "1-01-2012". Excel won't display the quotes and it should treat the value as text and not reformat it.

Cheers,

Amy

Former Member
0 Kudos

Hi Sankar,

You can try with the below code.

data : date        like sy-datum,

          datec(10) type c.

write date  to date10 dd-mm-yyyy.

(or)

.

Try to convert using below FM.

CONVERSION_EXIT_PDATE_OUTPUT   -  Conversion Exit for Domain GBDAT: YYYYMMDD  -> DD-MM-YYYY

Kind Regards,

Balaji


Former Member
0 Kudos

Hi

you can change the format of date in excel itself or the best way you can follow is pass value between single quotes. you may get solution.

0 Kudos

Hi,

My suggestion, format the column in excel to required data format and then paste the data in the cells using OLE concepts.

Thanks and regards,

Kartik