MySQL DATE_FORMAT Guide & Examples

The date_format function in MySQL is used to format date and time into a specified format. This function takes two parameters, the first one being the date and time value, and the second one being the format string to apply.

For example, you can use the date_format function to format the date and time as year-month-day: %Y-%m-%d. Here is an example code:

SELECT date_format('2022-01-01', '%Y-%m-%d');

The above code will return the formatted date and time value as “2022-01-01”. By using the date_format function, it is easy to convert date and time into a specified format to meet specific requirements.

bannerAds