684425 Posted August 6, 2020 Share Posted August 6, 2020 I have a column (unix_values) in table where multiple values are stored in unix timestamp which i want to convert into date yyyy-mm-dd and copy to another column (date_values) using single query Any help please? Quote Link to comment Share on other sites More sharing options...
Barand Posted August 6, 2020 Share Posted August 6, 2020 https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_from-unixtime 1 Quote Link to comment Share on other sites More sharing options...
684425 Posted August 6, 2020 Author Share Posted August 6, 2020 10 minutes ago, Barand said: https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_from-unixtime I was trying it with a subquery and got confused. Thank you 🙂 Quote Link to comment Share on other sites More sharing options...
Barand Posted August 6, 2020 Share Posted August 6, 2020 Just for the record... mysql> select * from datetest; +------------+------+ | unix | date | +------------+------+ | 1576972800 | NULL | | 1579651200 | NULL | | 1582329600 | NULL | +------------+------+ mysql> UPDATE datetest SET date = from_unixtime(unix); mysql> select * from datetest; +------------+------------+ | unix | date | +------------+------------+ | 1576972800 | 2019-12-22 | | 1579651200 | 2020-01-22 | | 1582329600 | 2020-02-22 | +------------+------------+ 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.