How to convert a bigint into a date type in MySQL?

In MySQL, the FROM_UNIXTIME() function can be used to convert a bigint value to a date type.

Assume there is a column named timestamp of type bigint, you can convert it to date type using the following statement:

SELECT FROM_UNIXTIME(timestamp) AS date_column FROM table_name;

After executing the above statement, a column named “date_column” will be returned, where the values will be the result of converting the values of a column of type bigint to type date.

Please note that the FROM_UNIXTIME() function interprets bigint values as Unix timestamps, which represent the number of seconds from January 1, 1970, to the specified time. Therefore, when using this function for conversion, make sure the bigint value is a valid Unix timestamp.

广告
Closing in 10 seconds
bannerAds