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: 

Default date format

Former Member
0 Kudos

Hi,

I want to get default date format for user.

I want to convert a text for example '01.01.2008' to default date format (YYYYMMJJ or JJMMYYYY in depend of user).

Thanks in advance.

18 REPLIES 18

Former Member
0 Kudos

Hi,

Use the FM

CONVERT_DATE_TO_INTERN_FORMAT

Regards

Lekha

former_member382216
Participant
0 Kudos

select the DATFM from USR01 table where bname = username.

data element is XUDATFM for datfm .select the fixed value from data element and choose the date format

Former Member
0 Kudos

CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'

EXPORTING

DATUM = '12.02.2001'

DTYPE = 'DATS'

  • IMPORTING

  • ERROR =

IDATE = lv_date

  • MESSG =

  • MSGLN =

Former Member
0 Kudos

Hi,

I hope this will help you,

HRGPBS_HESA_DATE_FORMAT

Regards,

Harish

Former Member
0 Kudos

Hi,

Use FM CONVERT_DATE_TO_INTERNAL.

Regards,

Raju.

Former Member
0 Kudos

hii

default format of date is yyyymmdd..so for that you can use FM

CONVERT_DATE_TO_INTERNAL

and for ddmmyyyy for mat you can use logic like below

data:wa_date like sy-datum,

wa_dt(10) type c.

Concatenate wa_date +6(2)wa_date +4(2) wa_date +0(4) into wa_dt.

result = wa_dt

regards

twinkal

Former Member
0 Kudos

HI,

check with the following FM.

SLS_MISC_GET_USER_FORMAT

former_member181995
Active Contributor
0 Kudos

Simo,

for getting default date from user:

use FM DATUMSAUFBEREITUNG.

data: idate TYPE sy-datum,
          tdat8 type string.
 idate              = <your date>
 CALL FUNCTION 'DATUMSAUFBEREITUNG'
     EXPORTING
       IDATE                 = idate
     IMPORTING
        TDAT8                 = tdat8"user's default date formate
    EXCEPTIONS
       DATFM_UNGUELTIG       = 1
       DATUM_UNGUELTIG       = 2
       OTHERS                = 3.

Amit.

0 Kudos

There's a problem with this functions. When i give a different date format in import parameter --> error...

That what i want to do:

I have a text for example '31.08.2008'. I want to convert it the format date of user. If 'YYYYMMJJ' ---> 20080831 and if 'JJMMYYYY' ---> 31082008 etc......

0 Kudos

Simo,

preriquiste of this FM is that , you must change all date before passing in YYYYMMDD formate which comes in idate ,and pass it to FM.you will get user format date .dont worry about user formate , FM would take care of it.

0 Kudos

Look Amit, please test it:

1- Change your default format date: Goto System -> user profile -> Own data and click on Defaults and change date format 'YYYY-MM-DD'

2- MF: 'DATUMSAUFBEREITUNG' with IDATE = '31082008'.

0 Kudos

You tested Amit?

Error because the format in not good

0 Kudos

The goal is to use MF 'SD_DATETIME_DIFFERENCE' because in import parameter (date1 and date2) we must use a default format date

0 Kudos

Simo,

look this piece of code.

data: idate TYPE sy-datum,
          tdat8 type string.
  LOOP AT it_excel.
idate              = p_budat.
    CALL FUNCTION 'DATUMSAUFBEREITUNG'
     EXPORTING
*       FLAGM                 = ' '
*       FLAGW                 = ' '
       IDATE                 = idate
*       IMONT                 = ' '
*       IWEEK                 = ' '
     IMPORTING
*       MDAT4                 =
*       MDAT6                 =
*       TDAT4                 =
*       TDAT6                 =
        TDAT8                 = tdat8
*       WDAT4                 =
*       WDAT6                 =
*     EXCEPTIONS
*       DATFM_UNGUELTIG       = 1
*       DATUM_UNGUELTIG       = 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.
      it_excel-budat_004 = tdat8.
MODIFY it_excel.
    CLEAR it_excel.
  ENDLOOP.

where p_budat is parameter with type budat.

it werk fine for me in BDC.where i suppose to put a posting date according to user format only.

Amit.

0 Kudos

My first value is char(10) not date not parameter.

data: v_data(10).

v_data = '31.08.2008' for example

My question is how can i do for converting this value on default date format for user?

Pramanan
Active Participant
0 Kudos

hi,

data: wa type string.

data: w_date type string.

wa = '01.11.2008'.

data:wa_year type char4.

data: wa_month type char2.

data: wa_date type char2.

replace all occurrences of '.' in wa with space.

wa_year = wa+4(4).

wa_month = wa+2(2).

wa_date = wa+0(2).

concatenate wa_year wa_month wa_date into w_date.

Write:/ w_date.

This will exaclty print your desired output.

former_member705122
Active Contributor
0 Kudos

Hi,

for this you can directly move the value of type sy-datum to type d and pass the value.

DATA:
  w_date TYPE d.
  w_date = sy-datum. " move value
  write: w_date.

Regards

Adil

Former Member
0 Kudos

This message was moderated.