SQLite 3 reference · 7 entries

SQLite Date and Time Functions

SQLite date functions date(), time(), datetime(), julianday(), unixepoch(), strftime() and timediff(), with modifiers such as '+1 month' and 'start of month'.

SQLite stores dates as ISO-8601 text, Julian day numbers or Unix times; these functions read any of them. Results are in UTC unless you add the 'localtime' modifier.

NameDescriptionSince
DATE() Return a date as text in YYYY-MM-DD form, optionally shifted with modifiers like '+7 days' or 'start of month'.
TIME() Return the time part of a date/time as text in HH:MM:SS form, optionally shifted with modifiers.
DATETIME() Return a date and time as text in YYYY-MM-DD HH:MM:SS form, optionally shifted with modifiers.
JULIANDAY() Return the Julian day number (days since 4714 BC, with a fraction for the time). Subtract two to get days between dates.
UNIXEPOCH() Return a date/time as a Unix timestamp: whole seconds since 1970-01-01 00:00:00 UTC. 3.38.0
STRFTIME() Format a date/time with % codes, such as %Y year, %m month, %d day, %H hour, %W week and %w weekday.
TIMEDIFF() Return the difference between two dates as text like '+0000-01-14 00:00:00.000' (years, months, days, time). 3.43.0

Was this page helpful?