转储日期存储为varchar作为timestamp错误

时间:2014-09-29 11:33:27

标签: sql parameters casting timestamp varchar

我将日期存储为VARCHAR(10)。我想选择时间戳

 SELECT     CAST (date AS TIMESTAMP)     AS created_timestamp
 FROM     dates;

我明白了:

 Incorrect parameters in the call to stored function 'CAST': SELECT CAST (date AS TIMESTAMP) AS created_timestamp FROM dates

我做错了什么?

1 个答案:

答案 0 :(得分:0)

您无法转换为MySQL中的时间戳。有一个名为TIMESTAMP的函数会为你做这件事。

SELECT TIMESTAMP(date) AS created_timestamp FROM dates;