在PostgreSQL中,查询30分钟前的数据的SQL怎样写?时间字段为Time,该如何解决

在PostgreSQL中,查询30分钟前的数据的SQL怎样写?时间字段为Time

在PostgreSQL中,查询30分钟前的数据的SQL怎样写?时间字段为Time

try

SQL code

select * from yourTable where time<now()-05/24


SQL code

postgres=# \d a
              Table "public.a"
 Column |          Type          | Modifiers 
--------+------------------------+-----------
 id     | integer                | 
 name   | character varying(100) | 
 t_time | time without time zone | 

postgres=# select * from a
postgres-# ;
 id | name  |     t_time      
----+-------+-----------------
  1 | 11111 | 09:35:37.738117
  2 | 22222 | 09:35:37.738117
  3 | 33333 | 09:35:37.738117
    | 34444 | 08:30:20
(4 rows)

Time: 0.297 ms
postgres=# select * from a where current_time - t_time > interval '30 minute';
 id | name  |  t_time  
----+-------+----------
    | 34444 | 08:30:20
(1 row)

Time: 0.519 ms
postgres=#


                        
    
    
                    
在PostgreSQL中,查询30分钟前的数据的SQL怎样写?时间字段为Time,该如何解决

相关文章:

你感兴趣的文章:

标签云: