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: 

Function module for date conversion in user defined format?

Former Member
0 Kudos
600

Hi All,

Is there any function module which accepts date in any format and outputs in the user specified format?

Thanks,

Anil.

5 REPLIES 5

Former Member
0 Kudos
169

hi,

1)

data: gd_date(10). "field to store output date

  • Converts SAP date from 20020901 to 01.09.2002

write sy-datum to gd_date dd/mm/yyyy.

  • Converts SAP date from 20020901 to 01.09.02

write sy-datum to gd_date dd/mm/yy.

2)

data: gd_date(8). "field to store output date

  • Converts SAP date from 20010901 to 01092001

gd_date(2) = sy-datum+6(2).

gd_date2(2) = sy-datum4(2).

gd_date+4(4) = sy-datum(4).

3)

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.

Regards,

Bijal

Former Member
0 Kudos
169

Hi,

Use the FM:

<b>CONVERT_DATE_TO_EXTERNAL</b> Converts date from system storage format to users specified display format

Hope this helps.

Reward if helpful.

Regards,

Sipra

sreeramkumar_madisetty
Active Contributor
0 Kudos
169

Hi

use the FM:

CONVERT_DATE_TO_EXTERNAL

which can be used to convert the date format from SAP formatt to user defined format.

Regards,

kumar

Former Member
0 Kudos
169

Hi,

You can use this logic.

w_date = syst-datum.

  • Select the Date format for the User.

SELECT SINGLE datfm INTO w_format

FROM usr01

WHERE bname EQ syst-uname.

IF syst-subrc IS INITIAL.

CASE w_format.

WHEN '1'.

CONCATENATE w_date0(4) w_date4(2) w_date+6(2)

INTO w_date.

WHEN '2' OR '3'.

CONCATENATE w_date0(4) w_date4(2) w_date+6(2)

INTO w_date.

WHEN OTHERS.

ENDCASE.

regards,

Mahesh

Former Member
0 Kudos
169

check fm

DATE_STRING_CONVERT

here in DATE_FORMAT you have to check the format

in my case

1 DD.MM.YYYY

2 MM/DD/YYYY

3 MM-DD-YYYY

4 YYYY.MM.DD

5 YYYY/MM/DD

6 YYYY-MM-DD

here if you pass 1 in DATE_FORMAT

DATE_STRING must be like 01/11/2007

it will return 01.11.2007.

here if you pass 5 in DATE_FORMAT

DATE_STRING must be like 2007/11/31

it will return 31.11.2007.

just check that ...

regards

shiba dutta