NOW() returns the current local date and time as a date-time, and takes no argument. In DuckDB the match is now() (or current_timestamp), which is a timestamp with time zone: cast it to TIMESTAMP before comparing it with a plain timestamp column. The examples below compare against NOW instead of showing it, so their results don't change from day to day.
Updated · Checked on the xmetric engine
What is the syntax?
NOW()
Returns a date-time: the current local date and time.
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.
Was each order placed before this moment?
Tableau
[Ordered]<NOW()
SQL (DuckDB)
SELECT Ordered <CAST (now() AS TIMESTAMP) AS result
FROM input
ORDERBY id
Every sample order is in the past, so the answer stays true; the blank row stays null. Without the cast, DuckDB compares a timestamp with a timestamp with time zone.
Ordered
Result
2021-01-0108:00
true
2021-01-0318:45
true
2024-02-2910:15
true
2024-12-2916:25:40
true
2024-12-3009:05
true
2025-01-3123:59:59
true
2025-03-0100:00
true
2025-03-0212:30:15
true
null
✓ The Tableau formula and the SQL return the same 9 rows.
Is NOW on the same day as TODAY?
Tableau
DATEDIFF('day', TODAY(), NOW())
SQL (DuckDB)
SELECTdate_diff('day', current_date, CAST (now() AS TIMESTAMP)) AS result
FROM input
ORDERBY id
Zero days apart: NOW is today's date with the current time added.
Result
0
0
0
0
0
0
0
0
0
✓ The Tableau formula and the SQL return the same 9 rows.
Where does a straight translation go wrong?
Common mistake
Why is now() never equal to today's date?
now() carries the time of day, so comparing it with current_date (midnight) is false all day except at the exact stroke of midnight. Truncate it to the day first, as DATETRUNC('day', NOW()) does.
Tableau
DATETRUNC('day', NOW()) =TODAY()
Tempting SQL
SELECTCAST (now() AS TIMESTAMP) = current_date AS result
FROM input
ORDERBY id
SQL that matches
SELECTdate_trunc('day', CAST (now() AS TIMESTAMP)) = current_date AS result
FROM input
ORDERBY id
Tableau
Tempting SQL
SQL that matches
true
false
true
true
false
true
true
false
true
true
false
true
true
false
true
true
false
true
true
false
true
true
false
true
true
false
true
✓ 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 Ordered <CURRENT_TIMESTAMP() AS result
FROM input
ORDERBY id
Tableau's help says it is the local system time; on a live connection that can be the database server's time, in another time zone. DuckDB's now() uses the session's TimeZone setting.
Does NOW change between rows?
No. It is evaluated once per query, so every row sees the same value. The same holds for now() in DuckDB, which is fixed at the start of the transaction.
Should I use NOW or TODAY?
Use TODAY when you compare dates and NOW when the time of day matters. [Due] < TODAY() means "due before today"; [Ordered] < NOW() means "placed before this second".