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

ParameterTypeRequiredDescription
timestampTIMESTAMPYesThe TIMESTAMP to format
formatVARCHARYesThe 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

Examples

Last update at: 2025/10/13 10:23:46