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 determine the date format of a date?

Former Member
0 Kudos

hi,

I need to ndetermine thye date format(field datfm) of a given date...

for eg if the date is 22.11.2006(DD.MM.YYYY) THE DATFM IS 1.

now this date can be of any forma not a fixed one..so i need the datfm for that..

Is there any function module for that ...Plis suggest..

4 REPLIES 4

Former Member
0 Kudos

Hi

In SAP All the dates are stored in the format YYYYMMDD

so we usually convert them to our format like DD.MM.YYYY and display

we can do offset to separate the date,month and year and concatenate to a string and display

You can also use the fun module

CONVERT_DATE_TO_INTERNAL

reward points if useful

regards

Anji

0 Kudos

In the function module which u have mentioned do i need to give the date in user profile format only or any other valid format..

Say my user profile datfm is mm/dd/yyyy...

and i want to conver the date to sap format which is of datfm dd.mm.yyyy.

so in the fm the datfm has to be the user one..

I am asking this question because

in conversion_exit_pdate_input the input date must be in user profile format other wise it gives error invalid date...

Former Member
0 Kudos

hi vijaya,

you can set mask the date in text elments.

and also you ve one function module as

<b>CONVERT_DATE_TO_INTERN_FORMAT</b>

to convert the date as you like internally.

thanks,

velu.

Former Member
0 Kudos

To know the date format of your system go to the following path:

1. open a sap session

2.Go to system on the toolbar -> user profile -> own data

3. Then go to the defaults tab (2nd tab).

here you can see and change your system's default date format.

You can also change a date to your systems date format by using the function module:

DATA: l_date(10) TYPE c.

PERFORM convert_date_format USING sy-datum l_date.

*&---------------------------------------------------------------------*
*&      Form  convert_date_format
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

FORM convert_date_format  USING    p_source TYPE any
                                   p_dest TYPE c.

  CLEAR p_dest.
  CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
    EXPORTING
      date_internal            = p_source
    IMPORTING
      date_external            = p_dest
    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.

ENDFORM.                    " convert_date_format