【问题标题】:proper way to compare two timestamp fields in Oracle在 Oracle 中比较两个时间戳字段的正确方法
【发布时间】:2015-10-08 22:53:36
【问题描述】:

假设我有两个时间戳类型列 timestamp_column1 和 timestamp_column2 我想比较 timestamp_column1 是否大于 timestamp_column2。 如何比较这两个时间戳?比较运算符是否与 Oracle 上的时间戳一起正常工作?

timestamp_column1 > timestamp_column2

这是正确的吗??
还是我必须将它们包装在某个函数中以将它们相互比较 比如 to_timestamp(timestamp_column1) > to_timestamp(timestamp_column2) ?

【问题讨论】:

    标签: oracle timestamp


    【解决方案1】:

    只要“时间戳”列真正使用日期或时间戳数据类型之一,那么通常的关系运算符就可以工作。

    您需要在函数中包装时间戳的唯一情况是它被错误地存储为字符串,或者您想以某种方式对其进行操作,例如将其截断为小时、日、周、月、年或其他不太谨慎的时间单位。

    【讨论】:

      猜你喜欢
      • 2017-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-04
      • 2017-06-24
      • 2015-01-02
      • 2019-02-27
      • 1970-01-01
      相关资源
      最近更新 更多