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: 

Regarding Date Formating

Former Member
0 Kudos

Hi All,

I have a issue regarding <b>Date</b> formatting.

At present i am getting date in SAP format to my internal table field. Format is <b>[YYYYMMDD]</b> <i>ex:</i> <b>20050902</b>.

I want to make that field in following format as : <b>DD-MMM-YYYY</b> <i>ex:</i> <b>02-SEP-2005</b>.

can any body solve my issue.

Thanks in advance.

Thanks & Regards,

Rayeezuddin.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
  • Using Function modules

************************

data: gd_date(8).

"field to store output date

  • Converts date from 20010901 to 01SEP2001

gd_date = sy-datum.

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'

EXPORTING

input = gd_date

IMPORTING

OUTPUT = gd_date.

Refer this link

http://www.sapdevelopment.co.uk/tips/date/date_format.htm

Kindly reward points and close the thread.

Praff

9 REPLIES 9

FredericGirod
Active Contributor
0 Kudos

Please read the SAP Documentation by pressing F1 on the key word WRITE.

(in an Unix world, the answer will be RTFM)

0 Kudos

Hi,

I had tried with that option but did not worked.

Any other solution without using any function module.

Thanks & Regards,

Rayeez.

Vinod_Chandran
Active Contributor
0 Kudos

Use the function module as given below.

data: w_date(10).

call function 'CONVERT_DATE_TO_EXTERNAL'

exporting

date_internal = <- Field in YYYYMMDD format

importing

date_external = w_date

exceptions

date_internal_is_invalid = 1

others = 2.

Message was edited by: Vinod C

0 Kudos

Hi vinod,

I want <b>YYYYMMDD</b> format field to be displayed in <b>DD-MMM-YYYY</b> format.

Above FM what u have given is not suited for exact requirement can u give a solution where by we can directly translate <b>YYYYMMDD</b> format field into <b>DD-MMM-YYYY</b> format.

Thanks for ur time.

Thanks & Regards,

Rayeez.

0 Kudos

Hi,

Can you try CONVERSION_EXIT_IDATE_OUTPUT?

Another way is to get the month name using 'MONTH_NAMES_GET and concatenate date and year with it.

Thanks

Vinod

Former Member
0 Kudos
  • Using Function modules

************************

data: gd_date(8).

"field to store output date

  • Converts date from 20010901 to 01SEP2001

gd_date = sy-datum.

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'

EXPORTING

input = gd_date

IMPORTING

OUTPUT = gd_date.

Refer this link

http://www.sapdevelopment.co.uk/tips/date/date_format.htm

Kindly reward points and close the thread.

Praff

0 Kudos

can you hardcode it with concatenate then it can be solved.

con.....' ' '-'' '-' into .........

regards

0 Kudos

Hi,

The FM <b>'CONVERSION_EXIT_IDATE_OUTPUT'</b> giving ouput as <b>SEP012001</b> instead of <b>01SEP2001</b> when giving input as <b>20010901</b>.

Do we need to make any changes to get it as 01SEP2001.

Thanks & Regards,

Rayeez.

Former Member
0 Kudos

Hi,

This the code

REPORT ztest2.

data: mydate type d,

mychar(11).

data C_T247 type T247 occurs 0 with header line.

mydate = sy-datum.

call function 'MONTH_NAMES_GET'

TABLES

MONTH_NAMES = C_T247

EXCEPTIONS

others = 9.

READ TABLE C_T247 WITH KEY MNR = mydate+4(2).

concatenate mydate6(2) C_T247-KTX mydate0(4) into mychar

separated by '-'.

write mychar.

Output: 02-SEP-2005

Svetlin

P.S. If you find an answer helpful, please assign reward points.

Message was edited by: Svetlin Rusev