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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

timediff(time-value-A, time-value-B)

Parameters

ParameterDescription
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

Months and days apartTry it yourself
SELECT timediff('2026-03-01', '2026-01-15') AS diff;

Output

diff
+0000-01-14 00:00:00.000
Time in the jobTry it yourself
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

VersionChange
SQLite 3.43.0Added

In other languages

Was this page helpful?