Reputation: 5
Why does this SQL statement:
Select cast(convert(1231231231,103) AS datetime)
cause an error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '103) AS datetime)' at line 1
I need to convert INT
to DATETIME
, how to make it work?
Upvotes: 0
Views: 4296
Reputation:
Since your integer is unix time you can use FROM_UNIXTIME(unix_timestamp)
: https://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime?
Upvotes: 1