Convert
My raw data contains a column for date which is formatted as (MM/DD/YY). When I pivot this I can group by years and months but it makes 1 row for the year and the other row for the month (see below). The end result I am looking for is the month and year on a single row of the pivot. (Jan-12, Feb-12)<br>
<br>
1) I know how to do format cells > custom > (MMM-YY). <br>
2) I also know how to do 3 separate columns for 1) =Month() 2) = Year() and 3) =Concatenate. <br>
<br>
The first option for format cells isn't sufficient because when I pivot I still have to group by months and years as it still recognizes the day. This puts the year and month on separate rows in the pivot<br>
The second option for concatenation could work but I would imagine there is a simpler way. <br>
<br>
Pivot today when grouped:<table width='628' border='0' cellspacing='0' cellpadding='0'><tbody><tr height='20'><td height='20'>2012</td><td></td><td></td><td></td></tr><tr height='20'><td height='20'>Jan</td><td>Feb</td><td>Mar</td><td>Apr</td></tr></tbody><colgroup><col span='4'></colgroup></table>

Convert date to different format with Format Cells. In Excel, you can convert date to other date format in the Format Cells function. Select the dates you want to convert, right click to select Format Cells from context menu. The other kind of cells (e.g. Rows 10 and below in our example) are not recognized as dates in Excel, because the day (treated as month) is greater than 12 and there is of course no 13th month. For instance, in cell A10 we have the text “1/13/2004” which we want to convert to the date 13 January 2004.

Convert Dates In Excel

Dates can be awkward in Excel. The most prevalent format worldwide is Day-Month-Year (DMY), but not all countries follow it. One such country you might have heard of that differs from this “standard” is the US, where it is commonplace to use Month-Day-Year (MDY).

Speaking from personal experience, I remember one project manager was nearly fired after he thought the deadline was 1 March 2015 when it was in fact 3 January 2015. This is the danger of 1/3/15, for example.

Convert dates in excel to textConvert dates in excel to month

To show you how to overcome this problem, I will illustrate with converting US dates to what is often known as the “European” date format. Now, I know many readers would prefer this to be the other way around. I apologise, but I am an Australian Brit with the appropriate regional settings on my machine, and it’s a little awkward to perform screenshots that way. Don’t worry though — just follow me in reverse.

The problem becomes significant when you receive date data in a spreadsheet that is not recognised by your regional settings — or worse, actually is, like my unfortunate project manager mentioned above. For me, my computer cannot make sense of US date formats such as those shown in the screenshot below.


I have left the data in “General” style deliberately so you can see only one entry, cell A4, is recognised as a number (date). The problem is, even that’s wrong as that represents 5 December 2022, not 12 May 2022.

How do I convert it? We could use Power Query / Get & Transform — but that’s not really what this article is about. There is an easy way in Excel — but first, let’s start with a hard way.

In the screenshot below, I have managed to fix the issue:

Convert


See? Easy. Oh, sorry, I didn’t display the formula I used to do this in the image. Here it is for cell C2:


Any questions?

I have provided the formula because I am frustrated by the number of times I have read on the internet that this is not possible formulaically. Rubbish. You would just be a little insane to do it that way.

I won't explain this formula. Suffice to say it only works for converting US dates to European dates; the text strings are delimited with “/” and do not contain “@” in the text string. If you want the conversion to go the other way, simply replace d/m/yyin all instances above with m/d/yy.

Having said that, I think we are all agreed we need another — simpler — way. Let’s start again. Back to the original data, I make a copy in cells C2:C11, as shown in the screenshot below.


I do this so I may retain the original data (it’s always best to keep a copy in case you make a mistake). Next, I highlight cells C1:C11(including the header) and click on Text to Columns in the Data Tools grouping of the Data tab of the ribbon (Alt+A+E):

Convert Dates In Excel To Text


This generates the Convert Text to Columns Wizard dialog box. In Step 1, choose the Delimited option and click Next.


This means the data will be split into columns based upon a specified delimiter. Except we are going to cheat and not do that. In Step 2, uncheck all delimiters and then click Next, as shown below:

Convert Dates In Excel To Yyyymmdd


Now we come to the step that we actually want. We don’t use the Text to Columns feature to split data into separate columns. No, I want Excel to recognise my data as dates.


In this final step, select the Date: option in the Column data format and choose the date format that matches the data as it currently isnot what you want it to be. You are asking Excel to recognise it. In my case, the data is in Month-Day-Year format (MDY), so this is what I selected. Once you have chosen, click Finish.


I think you will agree this is far simpler than the formulaic approach and, more importantly, works for all date scenarios — as long as the original dates are formatted consistently.

As you keep working with dates, you will appreciate more and more the need for consistent dates — and the fact that they really aren’t that difficult to manipulate once you know the tricks.

Convert Date In Excel To Yyyymmdd

— Liam Bastick, FCMA, CGMA, FCA, is director of SumProduct, a global consultancy specialising in Excel training. He is also an Excel MVP (as appointed by Microsoft) and author of Introduction to Financial Modelling. Send ideas for future Excel-related articles to him at liam.bastick@sumproduct.com. To comment on this article or to suggest an idea for another article, contact Jeff Drew, an FM magazine senior editor, at Jeff.Drew@aicpa-cima.com.