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

date format

Former Member
0 Likes
1,529

HI,

i will give date as 06/18/2007

i want get it format like mm/dd/yyyy

(not date i want format )

Is there any function module

Regards

suresh.d

Message was edited by:

suresh dameruppula

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,497

hi,

try with these function modules.

<b>CONVERT_DATE_TO_EXTERNAL</b> --->Converts date from system storage format to users specified display format.

<b>follo this link it deffinetly helps you..</b>

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap-FunctionmoduleforconvertinganyExternaldateformattoInternalformat&

regards,

Ashokreddy.

20 REPLIES 20
Read only

Former Member
0 Likes
1,497

Hi,

You can use CONCATENATE keyword to do the same.

Eg: -

p_date = '06/18/2007'.

CONCATENATE p_date3(2) '/' p_date0(2) '/' p_date+6(4) into p_date separted by space.

Reward Points if it is helpful

Thanks.

hari krishna.

Read only

Former Member
0 Likes
1,497

I think the date you give and the wanted format both are same

explain what exatly you want?

regards,

manju

Read only

0 Likes
1,497

Hello Manjunatha,

just i need which date format i given

Regards

suresh.d

Read only

0 Likes
1,497

Hi Suresh,

See my code.. and let me know . This should work.

Reward Points if it is helpful

Thanks.

hari krishna.

Read only

0 Likes
1,497

Hi hari,

Where is code????

Regards

suresh.d

Read only

Former Member
0 Likes
1,497

Hi,

Thre is No FM available use the below code.

date4 EQ 'X' OR date5 EQ 'X'. "Date format is like DD.MM.YYYY or DD/MM/YYYY

CONDENSE temp_date NO-GAPS.

IF STRLEN( temp_date ) EQ 10.

o_date0(4) = temp_date6(4).

o_date4(2) = temp_date3(2).

o_date6(2) = temp_date0(2).

<b>Reward points</b>

Regards

Read only

Former Member
0 Likes
1,498

hi,

try with these function modules.

<b>CONVERT_DATE_TO_EXTERNAL</b> --->Converts date from system storage format to users specified display format.

<b>follo this link it deffinetly helps you..</b>

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap-FunctionmoduleforconvertinganyExternaldateformattoInternalformat&

regards,

Ashokreddy.

Read only

Former Member
0 Likes
1,497

Hi,

You specified in mm/dd/yyyy. The required format should be in dd/mm/yyyy. I guess...If so, Look into my code.

Reward Points if it is helpful

Thanks.

hari krishna.

Read only

0 Likes
1,497

Hi,

if the date is 08/24/3007 i wnt to display only format like mm/dd/yyyy

if the date is 24/08/2007 i wnt to display only format like dd/mm/yyyy

Regards

suresh.d

null

Read only

0 Likes
1,497

Hi Suresh,

Then Please check my code and see if it works for you.

If the simple code using CONCATENATE keyword solves your problem ..why you want FM for that ?

You will have to enter date in mm/dd/yyyy format and then it will display in dd/mm/yyyy.

Reward Points for helpful answers.

Also close the thread once your problem is solved

Thanks.

hari krishna

Read only

0 Likes
1,497

I dont think ur requirement is possible.

Month & Date is a problem if its like 24/10/2007...ie means DD/MM/YYYY and 10/24/2007 it means MM/DD/YYYY.

But if you give date as 01/01/2007 then how will u interpret this MM/DD/YYYY or DD/MM/YYYY ??

Answer for your question is Its not possible.

Incase if you want to know the date format of any user goto USR01 & specify the user-name & you can find a field for date format.

Regards,

Sail

Read only

0 Likes
1,497

Hi Suresh,

Here you go: -

Data: p_user(10) type c.

eg: -

p_user = '08/24/2007'.

write p_user.

Read only

0 Likes
1,497

Hi Hari,

I need only format of the date

Regards

Suresh.d

Read only

0 Likes
1,497

you have been saying that you only want the date format.

as much as i understand, you are giving a date as input. Now after this you just want the date format in which it is specified or do you want the same date converted in a specific format??

If you want the format in which the input date is specified then i guess it will be tricky. For example you will not be able to determine if the date 04/04/2007 is actually in DD/MM/YYYY or MM/DD/YYYY.

in case you want to convert the date to a specific format, i guess you already have a number of replies.

Please clarify if I understand your question horribly wrongly.

regards,

Priyank

Read only

0 Likes
1,497

HI Priyanka,

just i want to display only date format.

and my problem was solved by Hari krishna

Regards

suresh.d

Read only

0 Likes
1,497

Hi Suresh,

Please reward Points and close the Thread.

Thanks.

Hari krishna.

Read only

Former Member
0 Likes
1,497

Hello friend ...

here is the code of the funtion module created by me for any types of dates input you will get it as

The following SAP's external formats which can be found in the user settings are supported in this function module.

DD.MM.YYYY

MM/DD/YYYY

MM-DD-YYYY

YYYY.MM.DD

YYYY/MM/DD

YYYY-MM-DD

please copy and paste int se37 and activate ....

FUNCTION z_convert_to_internal_format.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     VALUE(IM_INPUT) TYPE  CHAR10
*"  EXPORTING
*"     VALUE(EX_OUTPUT) TYPE  SYDATUM
*"  EXCEPTIONS
*"      INVALID_DATE
*"----------------------------------------------------------------------

* Get the format.

* DD.MM.YYYY
  IF im_input+2(1) = '.'.
    CONCATENATE im_input+6(4) im_input+3(2) im_input(2) INTO ex_output.
  ENDIF.

* MM/DD/YYYY
  IF im_input+2(1) = '/'.
    CONCATENATE im_input+6(4) im_input(2) im_input+3(2) INTO ex_output.
  ENDIF.

* MM-DD-YYYY
  IF im_input+2(1) = '-'.
    CONCATENATE im_input+6(4) im_input(2) im_input+3(2) INTO ex_output.
  ENDIF.

* YYYY.MM.DD
  IF im_input+4(1) = '.'.
    CONCATENATE im_input(4) im_input+5(2) im_input+8(2)  INTO ex_output.
  ENDIF.

* YYYY/MM/DD
  IF im_input+4(1) = '/'.
    CONCATENATE im_input(4) im_input+5(2) im_input+8(2)  INTO ex_output.
  ENDIF.

* YYYY-MM-DD
  IF im_input+4(1) = '-'.
    CONCATENATE im_input(4) im_input+5(2) im_input+8(2)  INTO ex_output.
  ENDIF.

* Check the valid date.
  CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
       EXPORTING
            date                      = ex_output
       EXCEPTIONS
            plausibility_check_failed = 1
            OTHERS                    = 2.

* Check if the output parameter is populated. otherwise raise an
* exception.
  IF ex_output IS INITIAL OR sy-subrc <> 0.
    RAISE invalid_date.
  ENDIF.

ENDFUNCTION.

otherwise ....

If you always want the user to enter the date in dd/MM/yyyy, you can do the following.

Goto Local Dictonary -> Simple types in your project and create a type known as "InputDate" (or whatever you feel) of built-in type 'Date'.

Now specifiy its format in the 'Representation' tab as "dd/MM/yyyy" (case-senstive).

Now declare a value attribute say "inputdate" in your context with this type and bind the inputfield to this context value attribute.

This will solve your problem.

But if you want the user to input date depending on the region he belongs, change the default locale date in Control Panel->Regional and Language Options->Change to English(UK) -> Customize -> Date Tab -> Sort Date Format to dd/MM/yyyy.

Now clear the cache, delete temporary files and restart the machine. This should solve the problem.

reward points if it is usefull ...

Girish

Read only

Former Member
0 Likes
1,497

still open

Read only

0 Likes
1,497

Hi Suresh,

This is ur reqirement

( i will give date as 06/18/2007

i want get it format like mm/dd/yyyy )

But both the dater formats are same.

What do you exactly want to say. Please be a bit clear.

Regards:

Sapna

Read only

0 Likes
1,497

Hi Suresh,

data: p_date(10) type c.

p_date = '10/24/2007'.

Try something like this: -

IF p_date+0(2) > 12.

write 'dd/mm/yyyy'. --> as per your requirement

ELSEIF p_date+3(2) > 12.

write 'mm/dd/yyyy'. --. as per your requirement

endif.

Thanks

Hari krishna