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: 

How to change date format from DD.MM.YYYY to DD-MMM-YYYY?

Former Member
0 Kudos

We have a requirement in ABAP wherein we want to show the date from the date picker in u201C 10-Sep-2008u201D format and not in u201C10.09.2008u201D as it is appearing in the screenshot shown below.

Currently we have binded the context to u2018DATSu2019 type and date is appearing as u201C10.09.2008u201D when user selects from the date picker , can anybody tell me which data type I have to use to get the format in u201C10-Sep-2008u201D in the screen.

Is date format dependent on User Profile , if yes I checked SU01 transaction also but could not find the format u201CDD-MMM-YYYYu201D.

Could you kindly help me on this?Thank you.

Please note the middle is MMM, three digits

10 REPLIES 10

Former Member
0 Kudos

Hi There

I am not sure if SAP can give you an o/p with MMM but if you already have the date with you say 10.09.2008 then you might want to concatenate the month .

09 wil stand for Sep and so you can do the following:

l_month = 'Sep'.

l_date has lets say your date of 10.09.2008.

Concatenate l_date0(2) l_month l_date6(4) into l_new_date separated by ' - ' .

l_new_date will now be 10-Sep-2008.

Thanks

Shivika

0 Kudos

Hi,

The function module

CONVERSION_EXIT_SDATE_OUTPUT

converts DD.MM.YYYY to DD-MMM-YYYY.

Regards,

R.Nagarajan.

naveen_inuganti2
Active Contributor
0 Kudos

Hi...

Use the function module..,

MONTH_NAMES_GET,

and then concatenate date with offsets.

Thanks,

Naveen.I

Former Member
0 Kudos

Hi,

Try this Below Sample Code...

TABLES : mkpf.

DATA : lv_date_low TYPE datum.

DATA : lv_date_high TYPE datum.

SELECT-OPTIONS : p_dates FOR mkpf-xblnr VISIBLE LENGTH 12.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dates-low.

CALL FUNCTION 'F4_DATE'

IMPORTING

select_date = lv_date_low.

IF lv_date_low IS NOT INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_SDATE_OUTPUT'

EXPORTING

input = lv_date_low

IMPORTING

output = p_dates-low.

ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dates-high.

CALL FUNCTION 'F4_DATE'

IMPORTING

select_date = lv_date_high.

IF lv_date_high IS NOT INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_SDATE_OUTPUT'

EXPORTING

input = lv_date_high

IMPORTING

output = p_dates-high.

ENDIF.

Regards,

Durai.V

Former Member
0 Kudos

Hi,

Try using the FMs below:


CONVERSION_EXIT_IDATE_INPUT 
CONVERSION_EXIT_IDATE_OUTPUT

Thanks,

Sriram Ponna.

former_member387317
Active Contributor
0 Kudos

Hi

See below code...

PARAMETERS : DATE TYPE SY-DATUM.

DATA : TEXT2(20).

CALL FUNCTION 'CONVERSION_EXIT_SDATE_OUTPUT'
  EXPORTING
    INPUT  = DATE
  IMPORTING
    OUTPUT = TEXT2.

WRITE : / TEXT2.

REPLACE ALL OCCURRENCES OF '.' IN TEXT2 WITH '-' .

WRITE : / TEXT2.

If u want it to be like in that format in Selection screen then u can use the loop at screen... Endloop.. and events to get the desired result...

Hope it will solve your problem..

Thanks & Regards

ilesh 24x7

former_member212653
Active Contributor
0 Kudos

Check out this code:



DATA: i_t247 TYPE STANDARD TABLE OF t247 INITIAL SIZE 0,
        wa_t247 TYPE t247,
        v_date TYPE datum,
        v_long_date TYPE c LENGTH 11.
v_date = sy-datum.
" Table T247 stores the 3 char text for months
SELECT * FROM t247 INTO TABLE i_t247
WHERE   spras = sy-langu.

READ TABLE i_t247 INTO wa_t247
WITH KEY mnr = v_date+4(2).
IF sy-subrc = 0.
  CONCATENATE v_date+6(2) wa_t247-ktx v_date+0(4)
  INTO v_long_date SEPARATED BY '-' .
  WRITE: /1 v_long_date.
ENDIF.

output will be:


25-SEP-2008

Edited by: Sourav Bhaduri on Sep 25, 2008 11:25 AM

Mohamed_Mukhtar
Active Contributor
0 Kudos

Hi Hoo,

Data : w_date type dats value '20080925',  "yyyymmdd 
          w_date1(10),
Constants : C(1) value '-'.
w_date1 = w_date.
 
concatenate w_date+6(2) w_date+4(2) w_date+0(4) into w_date1 separated by C.
 
Write : / w_date1.

Regards

Former Member
0 Kudos

Hello,

Use Concatenate Method.

Thanks.

Swati.

Former Member
0 Kudos

Hi ,

try this...

data: ws_input type sy-datum,

ws_date type char20.

ws_input = '20080321'.

CALL FUNCTION 'CONVERSION_EXIT_SDATE_OUTPUT'

EXPORTING

input = ws_input

IMPORTING

OUTPUT = ws_date

.

Replace All Occurences of '.' IN ws_date with '-'.

write ws_date.

Regards,

Sivappriya.