【问题标题】:exclude timestamps depending of a sub-timestamp (postgresql)根据子时间戳排除时间戳(postgresql)
【发布时间】:2016-10-28 10:54:06
【问题描述】:

我的数据如下所示:

 ID     | timespan
 ------ | ------
 1      | 12 days 23:45:00 
 2      | 02:45:00 
 3      | 23:45:00 
 4      | 10 days 03:30:00 

我想排除包括 23:45:00 在内的每个时间跨度 所以我得到这个输出

 ID     | timespan
 ------ | ------
 2      | 02:45:00 
 4      | 10 days 03:30:00 

where子句应该怎么写?

【问题讨论】:

  • timespan是什么数据类型?
  • 'timespan'的数据类型是'interval'

标签: postgresql timestamp where


【解决方案1】:
with data(id, timespan) as (
values
    ( 1, '12 days 23:45:00'::interval),
    ( 2, '02:45:00'), 
    ( 3, '23:45:00'), 
    ( 4, '10 days 03:30:00')
)
select *
from data
where timespan::text like '%23:45:00%';

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 2015-03-07
    • 2012-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多