DATE_FORMAT
All functions > DATE AND TIME > DATE_FORMAT
Returns a string from the given timestamp and format.
Signatures
Returns: A formatted string representation of the timestamp
DATE_FORMAT(timestamp: TIMESTAMP, format: VARCHAR) → VARCHAR sql
| Parameter | Type | Required | Description |
|---|---|---|---|
timestamp | TIMESTAMP | Yes | The TIMESTAMP to format |
format | VARCHAR | Yes | The format string (e.g., '%Y-%m-%d') |
Notes
- Formats timestamp according to the specified format string
- Format uses strftime-style placeholders (e.g., %Y for year, %m for month)
- Useful for custom date/time string representations
- Format syntax varies slightly by database engine
- Common patterns: '%Y-%m-%d' for date, '%H:%M:%S' for time
Examples
FeatureQL
SELECT
f1 := DATE_FORMAT(FROM_ISO8601_TIMESTAMP('2024-03-15T10:30:45'), '%Y-%m-%d'), -- Format as date only
f2 := DATE_FORMAT(FROM_ISO8601_TIMESTAMP('2024-03-15T10:30:45'), '%H:%M:%S') -- Format as time only
;Result
| f1 VARCHAR | f2 VARCHAR |
|---|---|
| 2024-03-15 | 10:30:45 |
On this page