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: 

Date Conversion???

Former Member
0 Kudos

Hi All,

Please tell me is there any Function Module for the conversion of date formats??

My requirement is to get date in this format DD.MM.YYYY even when the user uses any XYZ format.

Thanks in Advance!!!

Seema.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Seema,

Since your Date format is not decided(xyz format), I think you need to decide your approach.

To dispaly the Date form System Format to User Format the FM <b>'CONVERT_DATE_TO_EXTERNAL'</b> is used.

Consider this code.


REPORT zztest_arun_2.

DATA: e_date(10) type c VALUE '2/2/2006',
      i_date(10).

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
  EXPORTING
    date_external            = e_date
  IMPORTING
    date_internal            = i_date
  EXCEPTIONS
    date_external_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 : / 'CONVERT_DATE_TO_INTERNAL',
        / 'My   Date:' , e_date  ,
          'Conv Date:',  i_date.

          skip 2.

 CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
  EXPORTING
    DATE_INTERNAL                  = sy-datum
  IMPORTING
    DATE_EXTERNAL                  = e_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 : / 'CONVERT_DATE_TO_EXTERNAL',
         / 'My   Date:' , sy-datum,
           'Conv Date:',  e_date.

Regards,

Arun Sambargi.

5 REPLIES 5

former_member223537
Active Contributor
0 Kudos

HI,

Use FM CONVERT_DATE_TO_EXTERNAL

Best regards,

Prashant

0 Kudos

hi,

or simply use command: write... to (using edit mask)

->look F1 to write to

A.

Former Member
0 Kudos

Hi,

U can use,

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

Also,

http://www.sapdevelopment.co.uk/fmodules/fmssap.htm

might help you.

Former Member
0 Kudos

Hi Seema,

I do not think that there will be any FM that will convert 'any XYZ format' to the date format DD.MM.YYYY.You first have to specify the date format that you want to change.

Former Member
0 Kudos

Hi Seema,

Since your Date format is not decided(xyz format), I think you need to decide your approach.

To dispaly the Date form System Format to User Format the FM <b>'CONVERT_DATE_TO_EXTERNAL'</b> is used.

Consider this code.


REPORT zztest_arun_2.

DATA: e_date(10) type c VALUE '2/2/2006',
      i_date(10).

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
  EXPORTING
    date_external            = e_date
  IMPORTING
    date_internal            = i_date
  EXCEPTIONS
    date_external_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 : / 'CONVERT_DATE_TO_INTERNAL',
        / 'My   Date:' , e_date  ,
          'Conv Date:',  i_date.

          skip 2.

 CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
  EXPORTING
    DATE_INTERNAL                  = sy-datum
  IMPORTING
    DATE_EXTERNAL                  = e_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 : / 'CONVERT_DATE_TO_EXTERNAL',
         / 'My   Date:' , sy-datum,
           'Conv Date:',  e_date.

Regards,

Arun Sambargi.