- Instant help with your Sql coding problems

Convert INT to DATETIME in MySQL

Question:
How to convert INT to DATETIME in MySQL?
Answer:
SELECT FROM_UNIXTIME(event_time) AS formattedEventTime FROM events;
Description:

If a timestamp is stored as an INT in a MySQL database table, in some cases it may be necessary to convert it to a normal date string. 

The FROM_UNIXTIME function returns a representation of unix_timestamp as a datetime or character string value.

Please note that the value returned is expressed using the session time zone.

Share "How to convert INT to DATETIME in MySQL?"