我有一个时间戳2017-07-19 11:45:01,我希望它转换为 int。
询问:
select cast(max(event_timestamp) as INT) from error_messages where error_level='ERROR' and user_name='git'
Run Code Online (Sandbox Code Playgroud)
错误:
SQL Error [2366] [42846]: [Vertica][VJDBC](2366) ERROR: Cannot cast type timestamptz to int
[Vertica][VJDBC](2366) ERROR: Cannot cast type timestamptz to int
com.vertica.util.ServerException: [Vertica][VJDBC](2366) ERROR: Cannot cast type timestamptz to int
Run Code Online (Sandbox Code Playgroud)
你必须使用TIMESTAMPDIFF()这种方式:
SELECT TIMESTAMPDIFF(SECOND,'001-01-01 00:00:00', '2015-02-23 03:12:35');
timestampdiff
---------------
63560257955
Run Code Online (Sandbox Code Playgroud)
获得你想要的时间单位数(上面的秒数),因为你想要的时间戳......
| 归档时间: |
|
| 查看次数: |
13084 次 |
| 最近记录: |