【发布时间】:2016-09-12 02:08:24
【问题描述】:
我正在尝试从时间戳字段中获取日期部分。 我使用了这个 SQL 查询:
select timestamp, CAST(timestamp as date) as date from messages
我得到了以下结果:
--------------------------------------------
| timestamp | date |
--------------------------------------------
| 2016-05-15 10:22:54 | 2016-05-16 |
--------------------------------------------
如上所示,生成的日期字段返回错误的日期2016-05-16,而原始日期为2016-05-15。
我们如何解决这个问题?
【问题讨论】: