4.8/5
Home

Integrations

Plug Count neatly into your existing data infrastructure

For data teams

Collaborative, AI-driven data exploration and modelling

For product & growth

Faster access to the answers which matter

For leaders

Turning data into an engine of improvement

Pricing

Latest post

Meet the new Count Agent

Meet the new Count Agent

Docs

Guides, references, and API docs

Blog

Opinions, analysis, and the occasional uncomfortable truth about data.

Webinars

Join our experts for deep dives into data analytics and business intelligence

Gallery

Browse ready-to-use canvas templates and try them instantly

Sign in

Where to begin?

Start for free

Spin up a canvas and explore your data — a couple of clicks, no card.

Book a demo

See it live. Bring your questions — we’ll bring the answers.

Still not sure?

Send us a note — we’ll point you the right way.

Data to decisions, faster.

Compare

  • Count vs BI
  • Count vs Notebooks
  • Count vs Chatbots
  • Count vs Hex
  • Count vs Looker
  • Count vs Tableau
  • Count vs Thoughtspot

Learn

  • Blog
  • Webinars
  • SQL tutorials

Legal & security

  • Privacy Policy
  • Terms of Use
  • Cookies Policy
  • Trust Center
  • Security

Social

  • LinkedIn →
  • YouTube →
  • X →

Start with the hard question.

Ask Count anything — we’ll take you straight into a canvas.

Opens sign-up with your prompt ready for Count.

© 2026 Count Technologies Ltd. All rights reserved.

Careers →Book a Demo →
count

SQL Resources

Count is the best SQL IDE, wrapped up in the best data analysis tool, all inside the best BI platform.

ARRAY_AGG
Arrays Explained
Arrays Explained
CASE
CAST
COALESCE
CONCAT
COUNT [DISTINCT]
CURRENT_DATE
CURRENT_DATETIME
CURRENT_TIMESTAMP
DATETIME_DIFF
DATETIME_TRUNC
DATE_DIFF
DefinitionPractical InfoCommon QuestionsTroubleshooting Common ErrorsRelated Pages
DATE_TRUNC
Data Types
Dates and Times
EXTRACT
IF
MEDIAN
SUBSTR
String Functions Explained
TIMESTAMP_DIFF
TIMESTAMP_TRUNC
TIME_DIFF
TIME_TRUNC
UNNEST
Window Functions Explained
SQL Resources/BigQuery Standard SQL/DATE_DIFF

DATE_DIFF

DATE_DIFF function. Definition, syntax, examples and common errors using BigQuery Standard SQL. The DATE_DIFF function allows you to find the difference between 2 date objects.

ℹ️

See also DATETIME_DIFF, TIMESTAMP_DIFF, TIME_DIFF

Definition

The DATE_DIFF function allows you to find the difference between 2 date objects in the specified date_part interval.

Where date_part can be any of the following:

DATE_DIFF(date_expression_a, date_expression_b, date_part)
  • WEEK : Begins on Sunday
  • WEEK(): Begins on  where WEEKDAY can be SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, and SATURDAY.
  • ISOWEEK: Uses ISO 8601 week boundaries. ISO weeks begin on Monday.
  • ISOYEAR: Uses the ISO 8601 week-numbering year boundary. The ISO year boundary is the Monday of the first week whose Thursday belongs to the corresponding Gregorian calendar year.
days_differenceweeks_difference
366-5

Practical Info

  • If the first date is earlier than the second one then the output will be negative.

Common Questions

How to filter for the last n days?

A common SQL query WHERE clause is to just pull the data for the last n days. In this case, we can make use of DATE_DIFF and CURRENT_DATE:

SELECT
  DATE_DIFF(CAST('2021-01-01' AS DATE), CAST('2020-01-01' AS DATE), DAY) AS days_difference,
  DATE_DIFF(CAST('2021-01-01' AS DATE), CAST('2021-02-01' AS DATE), WEEK) AS weeks_difference
datedays_since
2021-01-2221
2021-01-2617

Troubleshooting Common Errors

Argument 2 of DATE_DIFF has incorrect type: expected date found datetime.

This one is all too common. If you're using DATE_DIFF, you'll need to make sure both of your dates are indeed DATE data types, and not DATETIME or TIMESTAMPs. It's usually easy enough to add a CAST(datetime_col as DATE) to your function:

SELECT
  date,
  DATE_DIFF(CURRENT_DATE(), date, DAY) AS days_since
FROM
  (
    SELECT
      CAST('2021-01-22' AS DATE) AS date
    UNION ALL
(    SELECT
      CAST('2020-01-25' AS DATE) AS date)
    UNION ALL
(    SELECT
      CAST('2021-01-26' AS DATE) AS date)
  ) AS table_3
WHERE
  (DATE_DIFF(CURRENT_DATE(), date, DAY) <= 30)

DATE_DIFF does not support the SECOND date part

Similar to the first common error, this about the compatibility of the argument data types and the function. To find the difference between times, you'll need to use DATETIME_DIFF, TIMESTAMP_DIFF, or TIME_DIFF.

Related Pages

  • DATETIME_DIFF
  • TIMESTAMP_DIFF
  • Dates & Times in BigQuery
DATE_DIFF(CAST('2020-01-01 10:44:22' as DATE),'2021-01-05', DAY) days_diff

Got a CSV?
See it differently in <2 mins

Get started for FREEWatch our CEO do it