Skip to main content
SQL • LESSON 35

DATEDIFF

How can we measure the duration or difference between two dates in days?

Intermediate3 Minutes540 XP
🤔 THE QUESTION

How can we measure the duration or difference between two dates in days?

💡 WHAT IS IT?

DATEDIFF calculates the count of interval units between two date timestamps.

🎯 WHAT IS IT USED FOR?

Customer retention duration, employee tenure, ticket resolution time, shipping delays.

💻 EXAMPLE
SELECT
name,
DATEDIFF(
  CURRENT_DATE,
  join_date
) AS days_worked
FROM employees;

🎯 Mission Objectives

Practice typing production-grade SQL code for DATEDIFF.

  • DATEDIFF
  • Date difference
  • Tenure calculations
  • Analytics