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.
Reference:
The from_unixtime reference
Share "How to convert INT to DATETIME in MySQL?"
Related snippets:
- Convert Unix timestamp to human readable date in MySQL
- Count total rows by year in MySQL
- Convert INT to DATETIME in MySQL
- Select year from a Unix timestamp in MySQL
- Group by year of Unix timestamp in MySQL
- Extract year from a date in MySQL
- Get current date in MySQL
- Get current year in MySQL
- Get last 30 days records in MySQL
Tags:
convert, int, integer, number, date, datetime, time, convert int to date, mysql Technical term:
Convert INT to DATETIME in MySQL