读书人

在PostgreSQL中查询30分钟前的数据的

发布时间: 2012-04-01 17:23:46 作者: rapoo

在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 apostgres-# ; 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 mspostgres=# select * from a where current_time - t_time > interval '30 minute'; id | name  |  t_time  ----+-------+----------    | 34444 | 08:30:20(1 row)Time: 0.519 mspostgres=# 

读书人网 >Mysql

热点推荐