Oracle SQL从表中选择记录,其中timestamp = today

问题描述 投票:1回答:2

我在oracle中有一个表,其中包含created_ts类型的timestamp(6) with timezone

我想选择created_ts> =今天的记录。因此,例如,如果我今天(2017年2月20日)运行查询,我想要所有记录,其中created_ts更新或等于02-20-2017 00:00:00。

我已经看过使用date使用trunc(sysdate)列进行此操作的示例,但还没有看到如何使用时间戳+时区列。

谢谢

sql oracle timestamp
2个回答
4
投票

我想你想要:

where created_ts >= trunc(current_timestamp)

0
投票

我建议保持数据类型的一致性,因为trunc(a_timestamp)将透明地返回DATE的数据类型。

也许吧

where created_ts >= cast(trunc(current_timestamp) as timestamp)

是一个更精确的选择。

© www.soinside.com 2019 - 2024. All rights reserved.