DATE_FORMAT()
All functions > DATE AND TIME > DATE_FORMAT()
Returns a string from the given date or timestamp and format.
Signatures
Returns: A formatted string representation of the date or timestamp
DATE_FORMAT(timestamp: DATE | TIMESTAMP, format: VARCHAR) → VARCHAR sql
| Parameter | Type | Required | Description |
|---|---|---|---|
timestamp | `DATE | TIMESTAMP` | Yes |
format | VARCHAR | Yes | The format string (e.g., '%Y-%m-%d') |
Notes
- Formats date or timestamp according to the specified format string
- Placeholders are interpreted by the execution target (often strftime-like, e.g.
%Y,%m) - Useful for custom date/time string representations
- Token spelling can differ between targets — consult the backend's formatting reference for edge cases
- Common patterns: '%Y-%m-%d' for date, '%H:%M:%S' for time (note: time components are zero for DATE inputs)
Aliases
STRFTIME
Examples
Date inputs
FeatureQL
SELECT
f1 := DATE_FORMAT(DATE '2024-03-15', '%Y-%m-%d'), -- Format a date as ISO string
f2 := DATE_FORMAT(DATE '2024-03-15', '%Y/%m/%d') -- Custom separator
;Result
| f1 VARCHAR | f2 VARCHAR |
|---|---|
| 2024-03-15 | 2024/03/15 |
Timestamp inputs — common patterns
FeatureQL
SELECT
f1 := DATE_FORMAT(FROM_ISO8601_TIMESTAMP('2024-03-15T10:30:45'), '%Y-%m-%d'), -- Date-only slice
f2 := DATE_FORMAT(FROM_ISO8601_TIMESTAMP('2024-03-15T10:30:45'), '%H:%M:%S'), -- Time-only slice
f3 := DATE_FORMAT(FROM_ISO8601_TIMESTAMP('2024-03-15T10:30:45'), '%Y-%m-%d %H:%M:%S') -- Combined date and time in one string
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR |
|---|---|---|
| 2024-03-15 | 10:30:45 | 2024-03-15 10:30:45 |
Edge cases
FeatureQL
SELECT
f1 := DATE_FORMAT(FROM_ISO8601_TIMESTAMP('2024-03-15T10:30:45'), '%Y-W%V') -- ISO week-style token (`%V`); week boundaries depend on the execution target
;Result
| f1 VARCHAR |
|---|
| 2024-W11 |