Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Preventing Excel from interpreting values as dates

The Problem

Microsoft Excel, in its infinite wisdom, chooses to interpret whatever it can as a date when opening a CSV file.

For example, I have exported some data from an external application and one of the fields contains data which is NOT a date, which looks like this:

1/3/1
1/3/2
1/3/3
etc.

When opening the CSV in Excel it displays these as

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

01/03/2001
01/03/2002
01/03/2003
etc

What I’ve tried

If I right-click > Format Cells > change to "text" or "general", it’s too late – by this time Excel already thinks it’s a date and so it changes that to a number like this:

36951
37316
37681
etc.

I’d rather edit the data in Excel (as opposed to a text editor).

Surely someone else has had this problem?

It’s 2023, and I thought it’s a bit ridiculous posting this without researching first as surely someone else had the same problem, alas here’s a list of Stack Overflow issues and why they aren’t relevant:

Date Format Changed in CSV File – talks about "saving the date in the desired format". Not applicable.

Keep Excel from converting dates when opening/saving CSV – sounds like the ticket – except that none of the solutions here actually discuss ways of preventing the automatic interpretation of dates by Excel.

Stop Excel from automatically converting certain text values to dates – talks about using a token in the CSV to prevent Excel. Again this is not okay as I need to maintain the CSV’s format as it’s a template file for importing data into another application.

Retroactively stop Excel from interpreting cell values as dates – talks about doing this retroactively, i.e. she has opened the file in Excel, saved it, then realised it after the fact and wishes to convert back to a specific format.

If someone has better duckduckgo-fu than I, please just link me to the answer.

The Question

Without resorting to changing my Windows regional settings, which apparently alters how dates are interpreted as opposed to actually preventing dates from being interpreted, can someone tell me how to achieve what I want here?

Failing that, I’ll gladly change Windows Regional Settings to get this job done, but I somehow feel that I shouldn’t have to do this, as I want Excel to allow me to work with the text in the CSV file without any interpretation at the point of opening the file.

>Solution :

Here’s a text file that I’ll use:

1/3/1, Hello
1/5/2, Bye

I have M365 Excel on Windows.

Let’s go to Data tab -> From Text/CSV

enter image description here

Excel asks me to choose my CSV file. After I chose it, Excel shows me what it believes it’ll import. As you noticed, 1/3/1 is converted to a date – which is what you don’t want.

enter image description here

At the bottom of that wizard is a button called Transform.

enter image description here

When I click on it, the results are shown in Power Query.

enter image description here

I’ll remove the step called Changed Type that Excel wisely introduced.

enter image description here

Data is then correctly interpreted as 1/3/1.

Click on Close and Load.

enter image description here

And there we have the data in Excel in the format we wanted.

enter image description here


Using Legacy Wizard

If you don’t have the legacy wizard, use https://officesmart.wordpress.com/2018/06/18/turn-on-the-legacy-wizards-in-microsoft-excel-365/ to turn legacy wizard ON.

Go to Data > Get Data > Legacy Wizards > From Text

enter image description here

Choose your file and keep the default option of Delimited.

enter image description here

Choose the Comma delimiter.

enter image description here

Click on the column of your choice and make sure it is marked as Text.

enter image description here

You can change other column’s data types as well by clicking on them and changing the type.

When you load the data, you will see no column headings. Just the data like so:

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading