Tableau error Dates

The calculation contains errors

DATEDIFF is being called with (string, date, date, integer). Did you mean (string, datetime, datetime, string)?

The fourth argument of DATEDIFF is the first day of the week, and it must be text such as 'sunday' or 'monday'. A number like 1 there gives the (string, date, date, integer) error.

Updated · Checked on the xmetric engine

Which formula raises it, and what fixes it?

Raises the error
DATEDIFF('week', [Order Date], [Ship Date], 1)
Tableau: DATEDIFF is being called with (string, date, date, integer). Did you mean (string, datetime, datetime, string)?

The xmetric engine rejects it too.

Fixed
DATEDIFF('week', [Order Date], [Ship Date], 'sunday')

On each of the 3 example rows it returns:

RegionOrder DateShip DateResult
East2025-01-052025-01-090
West2025-02-102025-02-110
West2025-03-012025-03-081

Why it works. Tableau reads start_of_week as a day name. With 'sunday', an order placed on Saturday 1 March and shipped on Saturday 8 March crosses one week boundary, so the result is 1. Pick 'monday' if your weeks start on Monday; the counts change.

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('week', [Order Date], [Ship Date], 2)

    Fixed

    DATEDIFF('week', [Order Date], [Ship Date], 'monday')

    The optional start of week is a day name in quotes, not a day number.

    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?

What is the default start of week?

It follows the data source's locale, usually Sunday in the US. Passing 'monday' as the last argument makes the calculation independent of locale.

Does the start of week change DATEDIFF('day', ...)?

No. It only matters when the date part is 'week'.

Where is this message documented?