Tableau error Dates

The calculation contains errors

DATEDIFF is being called with (string, date, string)

One of your dates is stored as text. DATEDIFF needs two real dates, so a string field such as Ship Date fails. Convert it with DATE() first, or DATEPARSE() if DATE cannot read the format.

Updated · Checked on the xmetric engine

Which formula raises it, and what fixes it?

Raises the error
DATEDIFF('day', [Order Date], [Ship Date])
Tableau: DATEDIFF is being called with (string, date, string)

The xmetric engine rejects it too.

Fixed
DATEDIFF('day', [Order Date], DATE([Ship Date]))

On each of the 3 example rows it returns:

RegionOrder DateShip DateResult
East2025-01-052025-01-094
West2025-02-102025-02-111
West2025-03-012025-03-087

Why it works. DATE() turns the text "2025-01-09" into a date, so both arguments are dates and DATEDIFF can count the days between them. The 'day' part stays a string; that one is supposed to be text. Changing the field's type to Date in the data source fixes it for every calculation.

The 3 example rows
RegionOrder DateShip Date
East2025-01-052025-01-09
West2025-02-102025-02-11
West2025-03-012025-03-08

What else raises this message?

  1. Raises it

    DATEDIFF('day', [Ship Date], TODAY())

    Fixed

    DATEDIFF('day', DATE([Ship Date]), TODAY())

    The text field must be converted before date math. DATE parses ISO text such as 2025-03-14.

    Checked on the xmetric engine: the first fails, the fix runs.

  2. Raises it

    DATEDIFF('month', [Ship Date], [Order Date])

    Fixed

    DATEDIFF('month', DATE([Ship Date]), [Order Date])

    Either argument can be the text one; convert whichever it is.

    Checked on the xmetric engine: the first fails, the fix runs.

Does my formula have this problem?

Paste your formula and run it on the example rows. It uses the fields [Region], [Order Date], [Ship Date]; rename yours to match.

Runs in your browser on the xmetric engine. Nothing is uploaded.

Which functions does this involve?

What do people ask about this error?

Why is my date column text in the first place?

Tableau reads a column as text when even a few values don't parse as dates, or the format is unusual (like 14.03.2025). Change the field type in the data pane, or convert it with DATE or DATEPARSE.

When should I use DATEPARSE instead of DATE?

Use DATEPARSE with an explicit pattern when the text isn't in a standard format: DATEPARSE('dd.MM.yyyy', [Ship Date]).

Where is this message documented?