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 format

Former Member
0 Kudos

Hi Guys,

I have to find out format of a date field which is stored in a field symobl.

assume <f1> = 11/11/2005.

I need to whether it is in MM/dd/yyyy or dd/mm/yy...like that.

After i need to convert this to a YYYYMMDD format...

Do i have any functionModules or logic exist for this.

Earliest response is appreciated.

Thanks in advance.

Raja.

Message was edited by: raja gurrala

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Raja,

For your Q 2 (convert this to a YYYYMMDD format..), use the function module <b>'CONVERSION_EXIT_IDATE_INPUT'</b>.

Make sure u give the input date is in the format <b>ddmmyyyy</b> or <b>dd.mm.yyyy</b>

Thanks

Kam

25 REPLIES 25

Former Member
0 Kudos

Raja,

For your Q 2 (convert this to a YYYYMMDD format..), use the function module <b>'CONVERSION_EXIT_IDATE_INPUT'</b>.

Make sure u give the input date is in the format <b>ddmmyyyy</b> or <b>dd.mm.yyyy</b>

Thanks

Kam

athavanraja
Active Contributor
0 Kudos

if the intention is to converti the external date format to internal format simply use the following FM

DATE_CONV_EXT_TO_INT

Regards

Raja

Former Member
0 Kudos

Hi Raja,

Can you please tell me Which Version of SAP you are Using, because Some FM's are Available in Some Versions of SAP Only.

Please get back to me Immediately, So that I will surely get you the Idea of it.

Thanks,

Satya Krishna .M

0 Kudos

we are on ECC5 (WAS6.4)

Regards

Raja

Former Member
0 Kudos

Hi

I don't know if there is a fm, but you can split the date and analyze the single values:

SPLIT <f1> AT '/' INTO DAY MONTH YEAR.

CONCATENATE YEAR MONTH DAY INTO DATE.

I think it won't be easy to know if the date format is MM/DD/YYYY or DD/MM/YYYY, you can be sure only if you can know how the date is stored in field symbol.

The format of the date usually depends on user attributes, if it's your case, check the table USR01, field DCPFM.

Max

Message was edited by: max bianchi

Former Member
0 Kudos

raja,

would this works for..

if my datefield format is ..

11/11/2005 or 11-11-2005...etc..

to give in export structure u mentioned..

Former Member
0 Kudos

satya,

i am using 4.6c.

can i have some FMs here..

0 Kudos

Hi Raja,

There is one FM to Convert the Date to the Internal Format. Whatever the Date Format, You can Pass that Date to this FM through FS, It Automatically Converts to the Internal Format of the System. Please use this FM.

<b>

CONVERT_DATE_TO_INTERN_FORMAT

</b>

Please Pass the Parameters of the DATA Format and the DTYPE as DATS.

Thanks,

Satya Krishna.M

0 Kudos

Hi Raja,

Please let you know more FM's, let me do R & D on this.

Please be Patient, Will let you know the Answer for this.;

Thanks,

Satya Krishna.M

Former Member
0 Kudos

Max ..easily i can split...and work out for my logic..

But

the problem in dif countries people use dif formats..

example dd/mm/yyyy or mm/dd/yyyy..or some other..

So if i split that how would i come to know that ..which is earlier two digits are day or months...

i hope u understand my problem..

0 Kudos

i am not sure whether function i mentioned in available in 4.6C

you can also use

CONVERT_DATE_INPUT

CONVERT_DATE_TO_INTERNAL

but these will allow you to pass only user specific date format as input

Regards

Raja

0 Kudos

I know it, dO you try to see the date format stored in USR01?

Max

0 Kudos

Raja,

Even if u split the date, u will have problem in recognization.

If suppose the Date is '11/12/2005' or '12/11/2005' or '09/12/2005'(for eq), then u would not be in a position to find the correct Day and Month!!!!!

Thanks

Kam

0 Kudos

Hi Raja

In the table T005X (field DATFM) you can find out the date format for country;

In the table USR01 (field DATFM) you can find out the date format for user.

Max

0 Kudos

Raja,

here is another FM, Which you can get the Format of the Date.

<b>SLS_MISC_GET_USER_DATE_FORMAT</b>

Thanks,

Satya Krishna Madasu

Former Member
0 Kudos

Hi satya,Draja,Max,kam...

Thank u very much for instant replies.

i am a junior level programmer.

I copied the <FS> to a l-dtmp char(10) field.

CALL FUNCTION 'DATE_CONV_EXT_TO_INT'

EXPORTING

I_DATE_EXT = l_dtmp

IMPORTING

E_DATE_INT = l_date.

I used this FM ..and i got the field into l_date also as 11/11/2005...

If i assign this to

standard date field...

it copied as ...20051111.( this is what i required)..

Is this solution ok?

works for all instances..

like..if the format is 11-11-2005..??

As i am a beginner ..i need clarification to include this solution to mine..

Message was edited by: raja gurrala

Former Member
0 Kudos

Hi Raja,

By using the function module 'SLS_MISC_GET_USER_DATE_FORMAT', you can get the format of the date in your system. Based on this you split that into year,month and date. Later you can write into whatever format you want.

Regards,

Rajavardhana Reddy

Former Member
0 Kudos

Guys ,

Needed clarification for my previous posting!!!..

<b>Experts..plz do make comments ..on my proposed solution and clarify my misgivings..</b>

0 Kudos

Hey Raja,

I have Cross Checked with the Date Format you have like 11-11-2005, you cannot give this type of format to the FM, Whether you should give without any wild characters into it.

you can give like 11112005 and its converts into the Standard Internal Format,

Please tell me raja, Whether the FM's Which is given by me, is useful to you for this Case.

Thanks,

Satya Krishna.M

Former Member
0 Kudos

Hi all,

IF i <b>use date_con_ext_to_int FM</b> it is working fine as per my requirement..

But when supposed to save the PO (As i am using this in an userexit for ME21).

at last step of saving ..it is givng error like

Use data format of the user.

can any body look into this problem.

Message was edited by: raja gurrala

0 Kudos

it looks like you need to pass the date in the user specific format.

first use date_con_ext_to_int to convert the date to internal format (YYYYMMDD) then use the following piece of code to conver that date to user specific format.

select single datfm into usr01-datfm from usr01 where
                                       bname eq sy-uname .
  if sy-subrc eq 0 .
    move: usr01-datfm to wf_datfm .
  endif .

if wf_datfm eq '1' .
    concatenate loc_date+6(2)
                loc_date+4(2)
                loc_date+0(4)
                into wf_date separated by '.' .
    condense wf_date .

  elseif wf_datfm eq '2' .
    concatenate loc_date+4(2)
                loc_date+6(2)
                loc_date+0(4)
                into wf_date separated by '/' .
    condense wf_date .

  elseif wf_datfm eq '3' .
    concatenate loc_date+4(2)
                  loc_date+6(2)
                  loc_date+0(4)
                  into wf_date separated by '-' .
    condense wf_date .
  elseif wf_datfm eq '4' .
    concatenate loc_date+0(4)
                  loc_date+4(2)
                  loc_date+6(2)
                  into wf_date separated by '.' .
    condense wf_date .
  elseif wf_datfm eq '5' .
    concatenate loc_date+0(4)
                  loc_date+4(2)
                  loc_date+6(2)
                  into wf_date separated by '/' .
    condense wf_date .
  elseif wf_datfm eq '6' .
    concatenate loc_date+0(4)
                  loc_date+4(2)
                  loc_date+6(2)
                  into wf_date separated by '-' .
    condense wf_date .
  endif .

Regards

Raja

Former Member
0 Kudos

Raja,

Thanks i will try n get back.

IF i use the split logic like...

l_date0(4) = l_dtmp6(4)..

etc..

at last i am making l_date ( which i am passing )yyyymmdd ..only...

then it is not giving any error..

IF i use the FM module then only ..it is giving problem.

remaining 2 FMs also working but...every one is giving error at the time of saving only..

0 Kudos

ok got your point. you say system accepts YYYYMMDD. then as suggested use the FM which i have given (DATE_CONV_EXT_TO_INT) and make sure that the variable for parameter E_DATE_INT is of type D.

if you use variable of type D the return will be in system format which is YYYYMMDD

Regards

Raja

0 Kudos

Hi Raja,

If you are working with BDC then there will be one problem. The date format for BDC process sets according to the login user format.

Then the BDC should take the date format according to the login user format.

Inorder to get that there is no need of using FM or any.

It quite simple to give two statments as follows:

Eg:

data: v_date like sy-datum value '20050912',

v_date1(8) type c.

write v_date to v_date1.

write v_date1.

Here Write statement sets the date according to the user format

Again i request your rewards for the useful answers.

Thanks,

Gopi

Former Member
0 Kudos

Hi Raja,

... and with FM DATE_CHECK_PLAUSIBILITY you can check

whether a certain format you have is a valid date or not interpretable yet.

regards

Andreas