CSV Files Explained: How to Import Without Breaking Dates

A CSV file has no idea what a date is. It stores text, with fields separated by commas, and the spreadsheet that opens it makes a guess based on regional settings. Most broken dates come from a guess that was wrong for the file’s origin. The fix is to stop the program guessing: import dates as text, convert them with a formula you can check, and count the failures before anyone uses the data.

Overview and Glossary

The terms below appear throughout this guide.

  • CSV (comma-separated values): a plain text file with one record per line and a delimiter between fields.
  • Delimiter: the character that separates fields. It is usually a comma, but files from locales that use a comma as the decimal mark often use a semicolon.
  • Locale: the regional settings a program applies when reading text, including date order, decimal mark and list separator.
  • Serial date: how spreadsheets store a date internally, as a count of days from a fixed starting point. Excel’s default Windows system counts from 1 January 1900.
  • ISO 8601: the yyyy-mm-dd format, for example 2024-04-03. It reads the same way in every locale.
  • Helper column: an extra column containing a formula that derives a clean value from a raw one. The raw column is left untouched.
  • Silent rollover: a date function returning a valid but wrong date instead of an error, for example turning 31 February into 2 or 3 March.
BalanceBloom Bookkeeping Studio

Skip the setup

BalanceBloom Bookkeeping Studio

Income, expenses, profit and loss and sales tax in one bookkeeping workbook for Excel and Google Sheets.

See it on Taskdale →

SOP 1: How CSV Files Store Dates

SOP 1.1: What a CSV file actually contains

A CSV file is text. The value 03/04/2024 is ten characters, and nothing in the file says it is a date, which part is the day, or which calendar it belongs to. A typical export looks like this:

order_id,order_date,amount
1001,03/04/2024,125.50
1002,14/02/2024,80.00
1003,05/11/2024,42.10

Everything in that file is a string until a program decides otherwise.

SOP 1.2: How spreadsheets guess on import

When a spreadsheet opens a CSV, it scans each column against the date patterns in its locale. In a UK locale, 03/04/2024 becomes 3 April 2024. In a US locale, the same text becomes 4 March 2024. Both results are valid dates, so the program raises no warning.

The guess is only ambiguous when both the first and second parts are 12 or less. When one part is above 12, the text can only be read one way. In a US locale, 14/02/2024 cannot be a date, so the cell stays as text. That produces the most common failure: a column where some rows are real dates and others are text, with the mixture hidden among values that look correct.

SOP 1.3: Why the problem often appears late

The first rows usually look fine, and the damage shows up later. Sorting, filtering, pivot tables, date arithmetic and charts all depend on the stored type, not the displayed text.

Take three text values: 03/04/2024, 14/02/2024 and 05/11/2024. Sorted as text, they run in order of day number: 03, then 05, then 14. The result is wrong, because the dates are 3 April, 5 November and 14 February. Sorted as true dates, they run 14 February, 3 April, 5 November. The sort looks plausible until someone checks a known date.

Choosing an Import Method

Three questions decide the method: how much control you need over date interpretation, whether the import will repeat, and how many rows are involved.

MethodDate controlRepeatableEffortBest forMain risk
Double-click the fileLow: program guesses from localeNoLowestA quick look at data with no datesSilent day and month swap
Import dialogue with automatic conversion turned off (for example, Google Sheets File > Import)Medium: dates stay as text until you convert themPartlyLowOne-off files of modest sizeManual formula work every time
Text import with column types set (Excel Data > From Text/CSV, or Power Query)High: you set the type and the locale per columnYes, with refreshMediumRecurring supplier or system feedsWrong locale chosen during set-up
Scripted or database load with explicit parsingHighest: each field is parsed by a defined ruleYesHighLarge files and automated pipelinesMaintenance when the source format changes

Most people working in spreadsheets should use the middle two rows. The double-click method is acceptable only when the file contains no dates, or when the dates are unambiguous ISO 8601 values.

SOP 2: Step-by-Step Import Workflow

Follow these steps in order for any CSV containing dates. The workflow takes longer than double-clicking the file, and it prevents the errors described above.

  1. Open the raw file in a plain text editor, not a spreadsheet. Confirm the delimiter, the header row and the presence of any byte order mark (BOM).
  2. Identify the date format and locale of the source system. Ask the supplier if it is not documented.
  3. Note the encoding. UTF-8 is the usual choice. If the first header appears as order_id, the BOM has been read as text.
  4. Import with every date column set to text, or with the column type set explicitly to Date using the source locale.
  5. Create a helper column that converts the text into a date, using the formulas in the next section.
  6. Create a validation column that confirms the converted date matches the original text.
  7. Count the failures. If the count is above zero, fix the source or the formula before continuing. Do not overwrite the raw column until the count is zero.

Keep an untouched copy of the original file, named with the date it was received. Without it, a mistake in step 5 cannot be reversed.

Petal and Penny Expense Tracker

Ready-made template

Petal and Penny Expense Tracker

A Google Sheets spending tracker with categories, monthly totals and a simple budget check.

See it on Taskdale →

Essential Spreadsheet Formulas and Functions for Date Repair

The functions below cover most date repair work. Each one assumes the raw value is in column B, starting at row 2, and that the converted date will go in column C. Adjust the cell references to suit your sheet.

SOP 3.1: Convert DD/MM/YYYY text to a true date

=DATE(RIGHT(B2,4), MID(B2,4,2), LEFT(B2,2))

RIGHT takes the four-character year, MID takes the two-character month starting at position 4, and LEFT takes the two-character day. The formula depends on fixed-width text with leading zeros. A value written as 3/4/2024 breaks it, so the raw data must be checked first.

SOP 3.2: Convert ISO 8601 text

=DATE(LEFT(B2,4), MID(B2,6,2), RIGHT(B2,2))

ISO text needs no locale judgement, so this is the most reliable conversion. DATEVALUE also accepts some ISO strings, but its results depend on the locale of the spreadsheet, so the explicit DATE form is safer for files that will be shared.

SOP 3.3: Convert MM/DD/YYYY text

=DATE(RIGHT(B2,4), LEFT(B2,2), MID(B2,4,2))

Use this only when the source system is documented as US-formatted. Swapping it for the SOP 3.1 formula on a UK file produces the same silent swap the import created in the first place.

SOP 3.4: Flag rows that did not convert

=IFERROR(DATE(RIGHT(B2,4), MID(B2,4,2), LEFT(B2,2)), "CHECK")

The IFERROR wrapper returns the word CHECK in place of an error, so failures stand out when you scan the column. To count them across the whole import:

=COUNTIF(C2:C5000, "CHECK")

Set the range to comfortably cover the file. Adding rows later does not extend a fixed range, so use a generous upper bound.

SOP 3.5: Catch silent rollovers

DATE does not reject impossible dates. DATE(2024,2,31) returns 2 March 2024 without an error. An IFERROR wrapper does not catch this, so a separate validation column is required. For DD/MM/YYYY text:

=AND(MONTH(C2)=VALUE(MID(B2,4,2)), DAY(C2)=VALUE(LEFT(B2,2)))

The formula returns TRUE when the converted date has the same month and day as the source text. It returns FALSE for any rollover. Count the FALSE values with =COUNTIF(D2:D5000, FALSE).

SOP 3.6: Display dates as fixed text

=TEXT(C2, "yyyy-mm-dd")

TEXT converts a date into a formatted string, which is useful when a downstream system needs ISO output. The format codes depend on the locale. In English-language Excel, yyyy and mm work. In German-language Excel, the year code is JJJJ, so the same formula returns an error or the wrong text. Document the locale of any file that uses TEXT, or avoid the function in shared workbooks.

SOP 3.7: Find the rows that did not import at all

=COUNTA(A2:A5000) - COUNT(C2:C5000)

COUNTA counts non-blank order IDs. COUNT counts cells holding numbers, which includes true dates. The difference is the number of rows whose date did not convert. A non-zero result means step 7 of the workflow has not been completed.

Common Mistakes

The following errors account for most date problems in practice.

  • Opening the file and saving over it. Once the original is overwritten with a locale-guessed version, the correct values are gone. Keep the raw file read-only.
  • Checking only the first rows. The first 20 rows of a supplier file are often from the same month. Errors tend to appear where the day exceeds 12, which may be deep in the file. Check the full column with the counts in SOP 3.4 and SOP 3.7.
  • Typing fractions and dates by hand during cleaning. In Excel, typing 1/2 into a cell that is formatted as a date produces 2 January of the current year. The error happens during cleaning, not only at import.
  • Losing leading zeros. A reference such as 00451 becomes 451 when the column is treated as a number. Postcodes, account numbers and some product codes are affected. Import these as text.
  • Ambiguous two-digit years. A value such as 01/02/03 could be 2001, 2002 or 2003 depending on the source. Some programs also apply a cutoff that reads 03 as 1903 or 2003. Ask for four-digit years.
  • Timestamps with offsets treated as plain text. A value such as 2024-04-03T23:30:00+01:00 may be read as text, or converted to the local time of the machine that opened it. A file generated at 23:30 in one time zone can appear on the wrong day in another.
  • Missing rows beyond the spreadsheet limit. Excel worksheets hold 1,048,576 rows. Rows beyond that limit are not loaded, and the import may give no visible warning. Compare the row count in the source with the row count in the sheet.

Worked Example: Supplier Order File

A UK supplier sends orders.csv every week. The dates are in DD/MM/YYYY format, and the file has three rows for this example.

order_id,order_date,amount
1001,03/04/2024,125.50
1002,14/02/2024,80.00
1003,05/11/2024,42.10
1004,31/02/2024,64.75

Row 1004 contains an impossible date, because February 2024 has 29 days. The aim is to convert the dates correctly and flag the invalid row.

Step 1: Inspect the file. Open it in a text editor. The delimiter is a comma, the header is on row 1, and the dates are DD/MM/YYYY. No BOM is present.

Step 2: Import with the date column as text. Use Data > From Text/CSV in Excel, set order_date to Text, and load the data. Do not allow automatic type detection to convert the column.

Step 3: Convert the dates. In C2, enter:

=DATE(RIGHT(B2,4), MID(B2,4,2), LEFT(B2,2))

Fill the formula down to row 5. The results are:

OrderRaw text (column B)Converted date (column C)Rollover check (column D)
100103/04/20243 April 2024TRUE
100214/02/202414 February 2024TRUE
100305/11/20245 November 2024TRUE
100431/02/20242 March 2024 (rolled over)FALSE

Step 4: Add the validation check. In D2, enter:

=AND(MONTH(C2)=VALUE(MID(B2,4,2)), DAY(C2)=VALUE(LEFT(B2,2)))

Row 1002 returns TRUE, because the converted month is 2 and the day is 14. Row 1004 returns FALSE, because the converted month is 3, not 2.

Step 5: Count the failures. In a summary cell, enter:

=COUNTIF(D2:D5000, FALSE)

The result is 1. The file is not ready for use until row 1004 has been corrected at source, or excluded and recorded.

What a US-locale import would have produced. Had the file been opened with a US locale and no column type set, row 1001 would show 4 March 2024, row 1003 would show 11 May 2024, and row 1002 would stay as text. Row 1004 would show 31 February as text too. The sort by date would place row 1002 at the bottom, and the total for March would include an order that belongs in April. None of these errors would produce a warning.

Step 6: Record the result. Log the file name, the row count, the number of rows converted, the number flagged, and the action taken. This record is the audit trail for any later query about the figures.

Decision Rule and Pre-Import Checklist

Use this rule for every CSV that contains dates.

  • If the dates are ISO 8601, convert them with SOP 3.2 and run the count in SOP 3.7.
  • If the dates are in a known regional format, import them as text and convert with SOP 3.1 or SOP 3.3, then run the rollover check in SOP 3.5.
  • If the source format is unknown, do not import it. Ask the supplier, then return to the workflow in SOP 2.
  • If the file recurs, move the import into a set-up that sets the column type and locale explicitly, so that the next file needs no manual judgement.

Before any imported file is used in a report, confirm the following:

  • The raw file is saved unchanged, with the receipt date in the file name.
  • Every date column was imported as text or with an explicit locale.
  • The conversion count in SOP 3.7 is zero.
  • The rollover count in SOP 3.5 is zero, or every flagged row has a recorded action.
  • The row count in the sheet matches the row count in the source.
  • Placeholder dates have been replaced with blanks or documented values.
  • A sample of at least three dates, including one above day 12, has been checked against the source by hand.
Sorbet Books Bookkeeping Spreadsheet

Get the finished file

Sorbet Books Bookkeeping Spreadsheet

A friendly income and expense tracker with monthly totals and a profit summary that builds itself.

See it on Taskdale →

Scroll to Top