8

I'm in the UK, I've got a problem where I've got a list of dates supplied in US format. Excel seems to treat the ones that are valid in both formats as UK dates, (e.g. 03/01/2012 becomes 3rd of January rather that 1st March), and treat the ones that aren't valid UK dates (e.g. 03/13/2012) as basic text. I assume this choice is something to do with my regional settings.

What I want is the system to recognise that this column of text is supplied in US date format, and convert it into the underlying date representation for calculations.

How do I do this?

EDIT: The dates are supplied in a CSV file of the form:

3/ 1/2012, 09:01     , 18:58     ,9.4,0.6

where 3/1 is 1st of March

3
  • When you say "supplied in US format", are you importing a CSV file? Apr 4, 2012 at 11:50
  • Yes, it's a CSV file with lines of the form: 3/ 1/2012, 09:01 , 18:58 ,9.4,0.6 Where 3/1/2012 is 3rd of March
    – deworde
    Apr 4, 2012 at 11:54
  • What is your system locale (as in what locale is set in Region & Language Options)?
    – dnbrv
    Apr 4, 2012 at 12:01

13 Answers 13

14

For Excel 2010, rather than opening your CSV file, create a new workbook, then on the DATA tab, select Get External DataFrom Text. This gets to the interface where you can specify how to interpret your text data, including how to handle dates.

1
  • 3
    This is the best solution. If the CSV is opened rather than imported, Excel will apply the General format to each cell. If a General-format cell is recognized as a date by Excel, Excel will internally change the value of the cell to a date-representing serial number. Excel recognizes dates based on your regional settings, so dates that appear to be DMY will be converted. Once this conversion takes place, your original date data is lost. That is why you must IMPORT rather than open your CSVs in Excel.
    – Excellll
    Feb 3, 2014 at 15:52
4

Change the file's extension from ".csv" to ".txt", then open with Excel. Excel will give you a text import wizard. Select 'delimited' on the first page, check 'comma' on the second, and on the third you'll be able to select the type for each column of data. One of the types is date and has a drop down with a variety of formats (m/d/y, d/m/y, etc, etc).

3

The real problem is that the dates are supplied in a formatted form, the first thing every beginner programmer learns is that never format the dates, they are just numbers that are interpreted to correct format.

So the real solution is : 1.Having the dates in numeric format, having failed that 2.Turn the dates into numeric format yourself and then having them displayed in a separate column in what ever date format.

Number 2 does not involve any programming, just keeping the original column format as general text, using a formula ( better would be a calculated a table column ) that turns it into the numeric form and another column that display that value as a date format to your liking.

3

I've come across the same problem but in a slightly different way. The dates being imported from a CSV file are UK format but where the dates are valid in both US & UK excel treats them as US format. My workaround is to parse the dates as text (using NumberFormat = "@") into the sheet then re-formating the cells afterwards as the correct date format (using NumberFormat = "dd/mm/yyyy").

Seems (to me anyway) the simplest way of doing it.

1

Probably you can do the following:

1) Change the date setting on your windows taskbar to US timing. Here's a guide on how to do so: http://www.sysprobs.com/change-date-format-windows-7-ddmmyyyy

2) Set US timing on excel. Go to format cells>Date>Locale>English (US)

This worked for me, hope it helps.

1

CONVERT US DATES TO UK DATES IN EXCEL/CSV

(you don't really want to be changing your locale settings)

This is a 2 stage process:

  1. To stop Excel trying to autoconvert some dates into UK format and then messing up the conversion, In Excel highlight the column and go to Data > Text to Columns.

    1. Select Delimited, Next
    2. Clear all the Delimiter tick boxes, Next
    3. Select data type of ‘Text’, Next

Don’t try and just set this via the formatting menu (right-click format cells), it will not work. Don't select Date on the 'Text to columns' either as this will convert US dates using UK settings, use 'Text'

[Also see dunxd's answer for importing csvs as well. This will also work if imported as txt.]


2. In a spare close-by column copy the following formula. Replace references to F2 with your starting cell. Format the column in whatever date format you choose.

=DATEVALUE(CONCATENATE((IF(MID(F2,4,1)="/",MID(F2,3,1),IF(MID(F2,2,1)="/",MID(F2,3,2),IF(MID(F2,6,1)="/",MID(F2,4,2),MID(F2,4,1))))),"/",IFERROR((IF(SEARCH("/",LEFT(F2,2)),LEFT(F2,1),LEFT(F2,2))),LEFT(F2,2)),"/",IF(ISERR(FIND("/",RIGHT(F2,3),1)),RIGHT(F2,4),RIGHT(F2,2))))

Note: this should work with dates in the following formats:

  • 1/1/14
  • 01/1/14
  • 1/01/14
  • 01/01/14
  • 1/1/2014
  • 01/1/2014
  • 1/01/2014
  • 01/01/2014

If your date is not separated by “/”s replace this delimiter in the formula above.

Hope it helps.


UPDATE 17-2-2014

As requested a bit of a breakdown:

Datevalue and Concatenate just create the final string in UK date format, so to the interesting bit:

a. Get the US Day (mid value)

((IF(MID(F2,4,1)="/",MID(F2,3,1),IF(MID(F2,2,1)="/",MID(F2,3,2),IF(MID(F2,6,1)="/",MID(F2,4,2),MID(F2,4,1)))))

The most tricky part. We are unsure of the date format. We know that there will be two "/" somewhere but we need to find where. The most tricky part is in a data such as 1/1/10 the second "/" could be as early as the 4th chr, where in a date like 10/10/10 the first "/" is the 3rd, where the second is the 6th chr. We need a way to tell the first and second "/" apart. Its lucky that a '1/1/' format is the only way a "/" could be the 4th chr so we can use this:

  • If "/" is the exact 4th chr (meaning d and m will be single chr), return the 3rd chr as the US day value.
  • If not (meaning that there must be at least one 2chr number in the US day or month), if the 2nd chr is a "/", then return the 3rd and 4th chr as the US day value.
  • If not, if the 6th chr is a "/" (meaning the date must be 2 doubles
    for day and month ie. '10/10/'), return the 4 & 5th chr as the US day value, otherwise return just the 4th chr as the US day value.

b. Get the US Month (left value)

IFERROR((IF(SEARCH("/",LEFT(F2,2)),LEFT(F2,1),LEFT(F2,2))),LEFT(F2,2))

Fairly simple,

  • If "/" exists in the leftmost 2 chr of the string, Return just the 1st chr
  • if not, return the first 2 chr
  • if error, its the same as not finding "/", so return the first 2 chr as well

c. Get the Year (right value)

IF(ISERR(FIND("/",RIGHT(F2,3),1)),RIGHT(F2,4),RIGHT(F2,2))

Simple,

  • if "/" exists in the last 3 chr of the string, return last 2 chr, if not return last 4 chr, (4 chr year or 2 chr year).

Hope this helps.

2
  • Would you please explain how this works? For example, decompose it into the arguments to CONCATENATE and explain what each one is (and why). Jan 28, 2014 at 23:01
  • The idea is to switch the DD and MM around. We are unsure of the date format (could be any above) so the first part of the formula is just basically searching for the first "/" and second "/" to determine the middle string length. The formula finds the middle value (MID) first (Day in US format) as this will be displayed first in the output (UK format). Then it does the same for the Left Value (Us month) using 'LEFT'. Then finally starting with 'IF(ISERR' it checks to see it "/" is contained in the last 3 char (using RIGHT). If so it assumes a 2 digit year, if not it assumes a 4 digit year.
    – Pete
    Feb 17, 2014 at 12:04
0

I have had the same problem, but in reverse: from Australian to US format.

Im my case I run a macro that opens the CSV file. One column of the file contains dates. After adding an extra column with some computed data, the macro saves it as a .XLS file. In the XLS file, a date that is valid in both formats will change, i.e. 1/11/12 will become 11/1/12. Note that my macro does not touch the date column in any way, and the CSV always has the correct format. This only seems to happen on the customer's PC which runs Office 2010. I have not seen it in Office 2000 or 2003.

The only way I've been able to get around it is to change the macro to import the CSV, instead of opening it, and specifying Text format for the date column.

I did consider another possibility, which is to have the macro shell something like a grep command to put a "space" in front of the dates. That stops Excel from interpreting it as a date (quotes around the dates do not help). I decided import was the cleaner way though. As there is no native Win utility to do the editing, I would have to install grep on the customer's PC.

0

I have had this problem for quite some time. It seems to be a commonly misunderstood problem. Specifically, that the computer will not necessarily recognize a date in the correct format. If you were to record a date in the DD/MM/YYYY format, excel would interpret it in a MM/DD/YYYY format. So 05/06/2012 would be meant as June 5, 2012, however Excel would interpret it as May 6, 2012. Similarly, if you were to enter 13/12/2012, where you meant Dec 13, 2012, Excel would not recognize the date at all, as there is no month 13.

In order to correct this problem, I have devised a formula that will flip the first two date numbers around. This can be used to convert US to UK, or vice versa.

=IF(ISERR(DATEVALUE(F10))=TRUE,DATE(RIGHT(TEXT(F10,"DD/MM/YYYY"),4),LEFT(TEXT(F10,"DD/MM/YYYY"),2),LEFT(RIGHT(TEXT(F10,"DD/MM/YYYY"),7),2)),IF(ISERR(DATEVALUE(TEXT(F10,"mm/DD/YYYY")))=TRUE,DATE(RIGHT(TEXT(TEXT(F10,"mm/DD/YYYY"),"DD/MM/YYYY"),4),LEFT(TEXT(TEXT(F10,"mm/DD/YYYY"),"DD/MM/YYYY"),2),LEFT(RIGHT(TEXT(TEXT(F10,"mm/DD/YYYY"),"DD/MM/YYYY"),7),2)),0))

This has worked for me exactly how I wanted it to, and I believe is a solution that does not yet exist out in the field. Please let me know if this works as well for you as it has for me.

PS. I was using Excel 2007 for this formula.

1
  • 2
    How would that flip 03/04/2013 to 04/03/2013? This seems far worse: it will convert some but not all dates, so you have a mix of US and UK dates.
    – MSalters
    Nov 15, 2013 at 12:07
0

I recently experienced a similar problem with Excel 2010. Excel interpreted dates not interpretable as US date format correctly i.e. any date with a day > 12. For all dates with day < 13, it displayed them in US mm/dd/yy format - all in the same column and all in the same format. My first course of action was to check that my settings in both Excel and Windows were English (Australia) or at the very least English (UK). Neither was correct so I changed both and restarted Excel as advised. This did not fix the problem. I reformatted the date column as text, inserted a couple of rows between the correct dates and the US dates, backfilled by dragging the copy handle then typed the correct dates into the new cells, dragged the contents of the other cells in the record into their ne location and deleted the dodgy rows. What I discovered when I reformatted the date column to date format was that, while my dates were now correctly oriented dd/mm/yyyy, Excel still recognised two different formats - one left justified, the other right justified and none of the format painting or other options would resolve this.

Bizarrely, when I tabbed from one of the left justified cells to the adjacent cell, the cell reformatted to the right justified version and retained the correct date format. I can't explain this given that Excel displayed the "Date" descriptor for both in the "Number section of the ribbon, but it fixed the problem.

0

The problem is that you have your date setting in excel set as (and some date) Date formats that begin with and asterik() respond to changes in regional date and time settings specified for the operating system. You need to go to your control panel and adjust the date and time format there as well to ensure no flipping of dates. Sometimes 01/11/2013 for example will flip to 11/01/2013 (where 11 is november) however 30/11/2013 will not flip, this is because ms does not recognize the 30th as a valid month. no formula required

0

Related information, and the answer to all problems:

Save all date and time information in one format only:
http://en.wikipedia.org/wiki/ISO_8601

Attach a display format field to the saved data, if needed.

0

If you're starting from a CSV file, use the Text Import Wizard as dunxd's answer suggests.

If you've already got data in Excel that is not being interpreted correctly, you can use the Text to Columns feature do the same thing that the Text Import Wizard does — no complex formulas required.

Here's an example where I've got 3 dates in US format but my current location is Australia where we use UK format:

enter image description here

Excel has misunderstood these dates, and has interpreted the first two as UK dates (incorrectly) and left the third one as text as it could not understand the format.

To Fix This:

  1. Select the cells containing the dates you want to fix

  2. Choose Data > Text to Columns

  3. Choose Fixed Width, click Next, and then Next again (you don't need to create additional columns)

  4. Change the column data format to "Date" and "MDY" (or whatever format your original dates are in)

    TIP: I also like to change the destination cell and place the result in a new column so that I can still see the old dates and verify they are correct.

  5. Choose Finish. Your dates have now been fixed.

  6. You can then apply whatever date formatting you prefer. Here I've printed the month name in full so you can see the correction has been correctly applied:

    Excel dates US to UK

What if Excel cannot recognise the date format?

Sometimes Excel doesn't recognise a date and leaves it as text. Here's one example:

2022-05-12T10:56:43.682783+00:00

In this example, I had to use the Text to Columns feature to split the text on the letter T and then again on the + symbol to extract the date and time separately. Then you'll have the date and time in separate cells where Excel can either recognise the format, or you can use the method above to fix it. If you need the date and time combined back together again, you can simply add them together (assuming Excel recognises them both as a date and time).

-1

Right click on the column, select format cells, choose first tab which is "Number", select category date, and on the right hand side, set "Locale" to "English (U.S.)".

1
  • Tried that. That alters the way an already recognised date is formatted within the cell (e.g. It knows it's a date, and this tells it how to display that date). It doesn't control what text representation of date is recognised as a date.
    – deworde
    Apr 4, 2012 at 11:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .