DATEDIFF()
DATEDIFF() is a SQL function in the Date/Time Functions category. Returns the number of days between two dates (date1 - date2). The syntax is DATEDIFF(date1, date2). It accepts date1, date2. It returns integer days. A typical example: SELECT DATEDIFF('2024-12-25', '2024-12-01'); -- 24 SELECT DATEDIFF(NOW(), hire_date) FROM employees; -- Days employed A close relative is NOW(), which returns the current date and time as a timestamp. A close relative is CURDATE(), which returns the current date without time. A close relative is DATE(), which extracts the date part from a datetime expression. More about this category: Date and time functions — NOW, DATE, EXTRACT, DATEDIFF, DATE_ADD, DATE_FORMAT. Related Date/Time Functions entries: NOW(), CURDATE(), DATE(), EXTRACT(), DATE_ADD(), DATE_SUB(), DATE_FORMAT(), STR_TO_DATE(). This page is part of the free SQL Reference documentation covering 762+ statements, functions, and clauses, each with syntax, parameters, return values, and examples for MySQL, PostgreSQL, SQL Server, and SQLite.