我有一张桌子
CREATE TABLE MY_TABLE (id int, my_date timestamp);
和数据:
INSERT INTO MY_TABLE (id, my_date) VALUES (1, '2015-08-04 05:41:02')
如何在my_date
中选择seconds
:2015-08-04 05:41:02 ----> H2 database
答案 0 :(得分:2)
答案 1 :(得分:1)
我建议以下查询:
SELECT
*,
CAST(DATEDIFF('SECOND','1970-01-01',MY_DATE) AS BIGINT) AS UNIX_TIMESTAMP
FROM MY_TABLE ;
请注意,可能不需要使用bigint转换...
这也有效:
SELECT
*,
DATEDIFF('SECOND','1970-01-01',MY_DATE) AS UNIX_TIMESTAMP
FROM MY_TABLE ;
答案 2 :(得分:0)
尝试:
SELECT parsedatetime(my_date, 'yyyy-MM-dd hh:mm:ss') FROM my_tabe