SQLite STRFTIME() Function
Example
Show the order dates as day/month/year:
SELECT OrderID,
STRFTIME('%d/%m/%Y', OrderDate)
FROM Orders;
Try it Yourself »
Definition and Usage
The STRFTIME() function formats a date and time. The format text has codes that start with %, like %Y for the year. See all the codes in the SQLite Dates chapter.
Tip: Also look at DATE().
Syntax
STRFTIME(format, time_value, modifier, ...)
Parameter Values
| Parameter | Description |
|---|---|
| format | Required. The format text, like '%d/%m/%Y'. Common codes: %Y year, %m month, %d day, %H hour, %M minute, %S second, %w day of the week (0 is Sunday), %j day of the year |
| 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
Return the year of each employee's birth date:
SELECT LastName, STRFTIME('%Y', BirthDate)
FROM Employees;
Try it Yourself »