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

Default date format

Former Member
0 Likes
4,399

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
Read only

Former Member
0 Likes
2,674

Hi,

Use the FM

CONVERT_DATE_TO_INTERN_FORMAT

Regards

Lekha

Read only

Former Member
0 Likes
2,674

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

Read only

Former Member
0 Likes
2,674

CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'

EXPORTING

DATUM = '12.02.2001'

DTYPE = 'DATS'

  • IMPORTING

  • ERROR =

IDATE = lv_date

  • MESSG =

  • MSGLN =

Read only

Former Member
0 Likes
2,674

Hi,

I hope this will help you,

HRGPBS_HESA_DATE_FORMAT

Regards,

Harish

Read only

Former Member
0 Likes
2,674

Hi,

Use FM CONVERT_DATE_TO_INTERNAL.

Regards,

Raju.

Read only

Former Member
0 Likes
2,674

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

Read only

Former Member
0 Likes
2,674

HI,

check with the following FM.

SLS_MISC_GET_USER_FORMAT

Read only

Former Member
0 Likes
2,674

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.

Read only

0 Likes
2,674

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......

Read only

0 Likes
2,674

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.

Read only

0 Likes
2,674

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'.

Read only

0 Likes
2,674

You tested Amit?

Error because the format in not good

Read only

0 Likes
2,674

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

Read only

0 Likes
2,674

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.

Read only

0 Likes
2,674

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?

Read only

Pramanan
Active Participant
0 Likes
2,674

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.

Read only

Former Member
0 Likes
2,674

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

Read only

Former Member
0 Likes
2,674

This message was moderated.