Application Development and Automation 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: 
Read only

Date format

Former Member
0 Likes
1,207

Hi,

Is there any function module to change the date format from YYYYMMDD to DDMMYYYY or MMDDYYYY. Very urgent....

Thanks.....

10 REPLIES 10
Read only

Former Member
0 Likes
1,080

HI,

You can write a small subroutine to do this.

If you call a FM for this small operation, it will consume some time for execution.

Regards

Subramanian

Read only

0 Likes
1,080

Hi,

But they need to use the existing FM. Can u tell me what is the FM.

Thanks..

Read only

Former Member
0 Likes
1,080

no need to go for a FM .

its just logic which u can built.

data = 20071212.

data10(2) = data6(2).

data12(2) = data4(2).

data14(4) = data0(4).

Regards

Prabhu

Read only

0 Likes
1,080

use

1) data d_date(10).

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

DATE_INTERNAL = SY-DATUM

IMPORTING

DATE_EXTERNAL = d_date

EXCEPTIONS

DATE_INTERNAL_IS_INVALID = 1

OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

write d_date.

2)data d_date like sy-datum value '20060701'.

data n_date(8) type d.

n_date0(2) = d_date6(2).

n_date2(2) = d_date4(2).

n_date4(4) = d_date0(4).

write n_date.

Amit Tyagi

Read only

Former Member
0 Likes
1,080

data : vdate like sy-datum value '20070101'.

write : / vdate .

it will write in dd.mm.yyyy format.

otherwise,

daat : date(8).

date(2) = vdate+6(2).

date2(2) = vdate4(2).

date+4(4) = vdate(4).

now date contain the format

regards

shiba dutta

Read only

Former Member
0 Likes
1,080

Hi Anil,

check this FM

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

DATE_INTERNAL = SY-DATUM

IMPORTING

DATE_EXTERNAL = sav_datum

EXCEPTIONS

DATE_INTERNAL_IS_INVALID = 1

OTHERS = 2

.

from 20060830 (yyyymmdd ) to 30.08.2006 ( dd mm yyyy ) format

Read only

Former Member
0 Likes
1,080

Hi,

Check this sample code..

DATA: V_DATE TYPE SYDATUM.

DATA: V_CHAR(8).

V_DATE = SY-DATUM.

CONCATENATE V_DATE6(2) V_DATE4(2) V_DATE(4) INTO V_CHAR.

WRITE: / 'DDMMYYYY - ', V_CHAR.

CLEAR: V_CHAR.

CONCATENATE V_DATE4(2) V_DATE6(2) V_DATE(4) INTO V_CHAR.

WRITE: / 'MMDDYYYY - ', V_CHAR.

Thanks,

Naren

Read only

Former Member
0 Likes
1,080

Hi,

Use the FM:

CONVERT_DATE_TO_EXTERNAL Converts date from system storage format to users specified display format

data: rd like SY-DATUM,

hd(10) type c.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

DATE_INTERNAL = SY-DATUM

IMPORTING

DATE_EXTERNAL = hd

  • EXCEPTIONS

  • DATE_INTERNAL_IS_INVALID = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

write: hd.

Hope this helps.

Reward if helpful.

Regards,

Sipra

Read only

Former Member
0 Likes
1,080

Hi anil,

The function module is convert_date_to_external.

this will convert the date format from yyyymmdd to the standard format.

Read only

Former Member
0 Likes
1,080

Hi,

Use this FM

CONVERSION_EXIT_PDATE_OUTPUT

input : 20070112

this will give the output : 12.01.2007

Thanks

Shiva