SQLite DATETIME() Function
Definition and Usage
The DATETIME() function returns a date and time as a text in the format YYYY-MM-DD HH:MM:SS.
Tip: Also look at DATE(), TIME().
Syntax
DATETIME(time_value, modifier, ...)
Parameter Values
| Parameter | Description |
|---|---|
| time_value | Required. A date or time, like '1996-07-04', '1996-07-04 14:30:00' or 'now' |
| modifier | Optional. Modifiers that change the date or time, like '+7 days', '-1 month', 'start of month', 'start of year', 'weekday 0' (the next Sunday) and 'localtime' |
Technical Details
| Return type: | Text |
|---|
More Examples
Example
Add 2 hours to a date and time:
SELECT DATETIME('1996-07-04 14:30', '+2 hours');
Try it Yourself »