Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Date Formatting.

Hi

I have a date which could be either 01.01.2006 or even 1.1.2006. Whenever the date appears as 1.1.2006, i need it to be converted to the format 01.01.2006. Can anyone providde me with the logic or is any FM available for this ?

Murali.

Tags:
Former Member replied

Hi Murali,

There is a FM for this purpose.

It is CONVERT_DATE_INPUT.

Just check this code.

parameters: a(12).

data: b type sy-datum.

CALL FUNCTION 'CONVERT_DATE_INPUT'

EXPORTING

input = a

  • PLAUSIBILITY_CHECK = 'X'

IMPORTING

OUTPUT = b

  • EXCEPTIONS

  • PLAUSIBILITY_CHECK_FAILED = 1

  • WRONG_FORMAT_IN_INPUT = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

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

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

ENDIF.

This will convert 1.1.2006 to 01.01.2006.

Hope your query is solved.

Regards,

SP.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question