Tableau function Date

Tableau ISDATE to SQL

ISDATE(string) returns true when the string is a valid date in a format Tableau recognises, and false otherwise, including for null. It accepts the same formats as DATE: "2021-01-01", "January 3, 2021", "12/30/2024" in a US English locale. DuckDB has no ISDATE; test whether the parse is non-null.

Updated · Checked on the xmetric engine

What is the syntax?

ISDATE(string)
string
a string. Date fields are not allowed.

Returns a boolean: true if the string is a valid date. False for null.

What does it return, and what is the SQL?

Each example runs on the same 9 sample rows twice: the Tableau formula on the xmetric engine, and the SQL in DuckDB.

Which text values are valid dates?

Tableau

ISDATE([Text])

SQL (DuckDB)

SELECT
  coalesce(try_cast(Text AS DATE), CAST (try_strptime(Text, '%B %d, %Y') AS DATE), CAST (try_strptime(Text, '%m/%d/%Y') AS DATE)) IS NOT NULL AS result
FROM input
ORDER BY id

Rows 1 to 6 are dates in four formats; "2025-02-29", "n/a" and the blank are not.

TextResult
2021-01-01true
January 3, 2021true
2024-02-29 10:15true
2024-12-29true
12/30/2024true
2025-01-31true
2025-02-29false
n/afalse
false

The Tableau formula and the SQL return the same 9 rows.

How do I convert only the valid ones?

Tableau

IIF(ISDATE([Text]), DATE([Text]), NULL)

SQL (DuckDB)

SELECT
  coalesce(try_cast(Text AS DATE), CAST (try_strptime(Text, '%B %d, %Y') AS DATE), CAST (try_strptime(Text, '%m/%d/%Y') AS DATE)) AS result
FROM input
ORDER BY id

DATE already returns null for invalid text, so in SQL the parse alone does it.

TextResult
2021-01-012021-01-01
January 3, 20212021-01-03
2024-02-29 10:152024-02-29
2024-12-292024-12-29
12/30/20242024-12-30
2025-01-312025-01-31
2025-02-29null
n/anull
null

The Tableau formula and the SQL return the same 9 rows.

Where does a straight translation go wrong?

Common mistake

Why does try_cast(Text AS DATE) IS NOT NULL reject real dates?

DuckDB casts only ISO text, so "January 3, 2021" and "12/30/2024" fail the cast. Tableau recognises both. Try each format you expect.

Tableau

ISDATE([Text])

Tempting SQL

SELECT try_cast(Text AS DATE) IS NOT NULL AS result
FROM input
ORDER BY id

SQL that matches

SELECT
  coalesce(try_cast(Text AS DATE), CAST (try_strptime(Text, '%B %d, %Y') AS DATE), CAST (try_strptime(Text, '%m/%d/%Y') AS DATE)) IS NOT NULL AS result
FROM input
ORDER BY id
TextTableauTempting SQLSQL that matches
2021-01-01truetruetrue
January 3, 2021truefalsetrue
2024-02-29 10:15truetruetrue
2024-12-29truetruetrue
12/30/2024truefalsetrue
2025-01-31truetruetrue
2025-02-29falsefalsefalse
n/afalsefalsefalse
falsefalsefalse

The SQL that matches returns the Tableau result on every row; the marked cells are where the tempting SQL differs.

How do I write it in Snowflake or BigQuery?

The first example, written for each warehouse from its documentation. These are not run here; DuckDB is.

Snowflake

SELECT TRY_TO_DATE(Text) IS NOT NULL AS result
FROM input
ORDER BY id

Snowflake documentation

BigQuery

SELECT SAFE_CAST(Text AS DATE) IS NOT NULL AS result
FROM input
ORDER BY id

BigQuery documentation

What does your own ISDATE formula return?

Edit the formula and run it on the 9 sample rows. Fields: [id], [Ordered], [Due], [Text], [Local], [Y], [M], [D].

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

Which functions go with it?

What do people ask about ISDATE?

Can ISDATE take a date field?

No. Tableau's help says the argument must be a string; on a date field there is nothing to test.

What does ISDATE return for a null?

False, not null. The blank last row returns false; IS NOT NULL in SQL does the same.

Does ISDATE check that the day exists?

Yes. "2025-02-29" is false, because 2025 is not a leap year.

Where is this documented?