MySQL: Convert INT to DATETIME

前端 未结 4 1378
悲哀的现实
悲哀的现实 2020-12-08 13:00

I have a UNIX-type timestamp stored in an INT column in MySQL. What is the proper way to retrieve this as a MySQL DATETIME?

(I found t

相关标签:
4条回答
  • 2020-12-08 13:22
    SELECT  FROM_UNIXTIME(mycolumn)
    FROM    mytable
    
    0 讨论(0)
  • 2020-12-08 13:24
    select from_unixtime(column,'%Y-%m-%d') from myTable; 
    
    0 讨论(0)
  • 2020-12-08 13:29

    FROM_UNIXTIME()

    0 讨论(0)
  • 2020-12-08 13:42

    The function STR_TO_DATE(COLUMN, '%input_format') can do it, you only have to specify the input format. Example : to convert p052011

    SELECT STR_TO_DATE('p052011','p%m%Y') FROM your_table;
    

    The result : 2011-05-00

    0 讨论(0)
提交回复
热议问题