How to convert a SQL timestamp to a date?

In SQL, you can use the DATE_FORMAT function to convert a timestamp to a date. Here is an example:

SELECT DATE_FORMAT(FROM_UNIXTIME(timestamp_column), '%Y-%m-%d') AS date
FROM your_table;

In this example, timestamp_column is the name of the column containing timestamps, and your_table is the name of the table containing this column. The DATE_FORMAT function converts the timestamp generated by the FROM_UNIXTIME function into a specified date format (‘%Y-%m-%d’ representing year-month-day) and displays the result in a column named date.

bannerAds