2

I have been searching it for an hour but unfortunately nothing found that actually work. I have an excel sheet with a column having date in it. Current date format is dd.mm.yyyy but I want to change date format to yyyy/mm/dd for entire cell.

5 Answers 5

7

OPTION 1)

Assuming that you source date that is in the number format dd.mm.yyyy stored as an excel date serial and only formatted to display as dd.mm.yyyy then the best fix is to select the cells you want to modify. Go to your home tab, and select the number format and change it to General. See Green circles in image below. IF the format is already set to general, or when you switch it to general your numbers do not change, then it is most likely that your date in dd.mm.yyyy format is actually text. and will needed to be converted as per OPTION 2 below. However, if the number does change when you set it to general, select the arrow in the bottom right corner of the number area (see red circle).

Cell number format location

After clicking the arrow in the red circle you should see a screen similar to the one below:

Custom number format

Select Custom from the category list on the left, and then in the Type bar enter the format you want which is yyyy/mm/dd.

OPTION 2

=date(Right(A1,4),mid(A1,4,2),left(A1,2))

This assumes your original date is a string stored in A1, and converts the string to a date serial in the form excel stores dates in.1 You can copy this formula down beside you dates. You can then apply cell formatting for the date as described above, or use the build short or long date if that style matches your needs.

1Excel counts the number of days since January 0 1900 for the windows version of excel. I believe mac is 1904 or 1905.

1
  • 1) What column are you dates in? 2) =LEN(A1) ,where A1 is one of the cells with your date, what is the number that is returned?
    – Forward Ed
    Jun 3, 2016 at 10:39
6

The problem is that your date is a text string, so changing the cell number format won't have any effect.

One method of convert the dates in place to "real" dates is to use the Text to Columns wizard.

  • Select your date(s).

  • Select the Text to Columns option on the Data Tools Tab of the Data Ribbon:

enter image description here

  • At Step 1, select "Fixed Width" then "Next"

enter image description here

  • Step 2 is irrelevant

  • At Step 3, for the date column, select DMY as the format. You can also select the "Destination" if you want the results written elsewhere.

  • Then "Finish".

enter image description here

That's it. Your dates will be converted in place

Since your dates are now "real" Excel dates, you can use the Cell ► Number Format dialog to change the format to whatever you want.

2
  • I thought of that method too, but if I recall correctly it only works if the date format to be converted is recognized by excel to begin with right? otherwise you are left with the text you started with?
    – Forward Ed
    Jun 3, 2016 at 10:49
  • 1
    @Forwarded Unlike the Excel worksheet, in the TTC wizard, the date format of the data is known (supplied by the user). So it will convert most dates that have some recognizeable format, even when the worksheet sees text. Jun 3, 2016 at 11:07
2

Nothing wrong with your format i.e. yyyy/mm/dd. You can use:

=TEXT(A1,"yyyy/mm/dd")

enter image description here

Update

A comment was made on this question re the TEXT function converting a date-serial to text. It will still be possible to apply date functions to the output of the TEXT function and get an output. E.g. here we can see WEEKDAY returning a result on the value of B1 (which in turn is formatting A1): enter image description here

16
  • =TEXT(A1,"yyyy/mm/dd") is not working. Its showing the same result Jun 3, 2016 at 9:51
  • @Robin, seems to work if the text string of the date matches a date format recognized by excel. Failed when the date format is not in one recognized by excel. When excel can recognize the string as a valid format it automatically converts it to a date for math and functions.
    – Forward Ed
    Jun 3, 2016 at 9:57
  • @Robin Does your formula still work when you change the dashes (-) to decimals (.)?
    – Forward Ed
    Jun 3, 2016 at 10:08
  • @ForwardEd Yes, it does. In my example, A1 is a date serial with a format applied through the GUI in the same manner as Option 1 in your answer. I was trying to give an answer that worked without using the GUI. Nothing wrong with that in the slightest, but assumed the OP wanted a formula-based answer. Jun 3, 2016 at 10:12
  • @Robin I tried your formula on text entered as 03.06.16 and I got an error message with it. I believe it has to do with system settings date formats. I know my excel does not recognize all date formats as dates, such as the decimal separation. That is why I had asked the question if it worked for you.
    – Forward Ed
    Jun 3, 2016 at 10:19
0

You are making this way too complicated. Just use the DATE(year,month,day) function and switch the DAY() and YEAR() inside it.

If in cell A1 you have a European-style date in this format: 12-04-2017; Excel will interpret this as Dec 4, 2017.

Excel will interpret it properly as Apr 12, 2017 if you change it to the American-style of 04-22-2017 by writing this equation in another cell: "=DATE(YEAR(A1),DAY(A1),MONTH(A1))".
(I put the DAY() in the month spot and the MONTH() in the day spot.) Now you can use any date format you want.

-1

I use 'substitute' to replace the '.' with a '/'. Then use the date format to get the correct format.

1
  • 2
    This won’t work for the original poster as they expect year (yyyy) to come first, followed my month (mm) and finally date (dd).
    – Algamest
    Dec 1, 2021 at 13:20

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.