DATE_FORMAT
All functions > DATE_AND_TIME > DATE_FORMAT
Returns a string from the given timestamp and format.
Syntax
DATE_FORMAT(timestamp, format)
sql
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
timestamp | TIMESTAMP | Yes | The TIMESTAMP to format |
format | VARCHAR | Yes | The format string (e.g., '%Y-%m-%d') |
Returns
A formatted string representation of the timestamp
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