SQLite 3 reference · Date and Time Functions
SQLite TIMEDIFF() Function
Return the difference between two dates as text like '+0000-01-14 00:00:00.000' (years, months, days, time).
SQLite 3 Since 3.43.0
Syntax
timediff(time-value-A, time-value-B)
Parameters
| Parameter | Description |
|---|---|
A, B |
Two date/time values; the result is A minus B. |
Return value
Text (+|-)YYYY-MM-DD HH:MM:SS.SSS, or NULL.
Examples
SELECT timediff('2026-03-01', '2026-01-15') AS diff;
Output
diff +0000-01-14 00:00:00.000
SELECT name, timediff('2026-10-22', hire_date) AS tenure
FROM employees
WHERE employee_id IN (1, 10);
Output
name | tenure Sofia Reyes | +0008-07-21 00:00:00.000 Ravi Kumar | +0002-00-21 00:00:00.000
Version history
| Version | Change |
|---|---|
| SQLite 3.43.0 | Added |
In other languages
AGE()· PostgreSQL
Related
JULIANDAY()· Return the Julian day number (days since 4714 BC, with a fraction for the time). Subtract two to get days between dates.DATE()· Return a date as text in YYYY-MM-DD form, optionally shifted with modifiers like '+7 days' or 'start of month'.- SQL Date Functions · tutorial