当前位置:   article > 正文

postgresql数据库查询几年内几月内几日内数据_pg 查询半年的数据

pg 查询半年的数据

获取5年内的数据

 select create_time
 from xj_check as n
 where  n.create_time>=to_timestamp(substring(to_char(now(),'yyyy-MM-dd hh24:MI:ss') FROM 1 FOR 10),'yyyy-MM-dd')- interval '5 year'    order by create_time desc 
  • 1
  • 2
  • 3

在这里插入图片描述

获取5月内数据

select create_time
 from xj_check as n
 where  n.create_time>=to_timestamp(substring(to_char(now(),'yyyy-MM-dd hh24:MI:ss') FROM 1 FOR 10),'yyyy-MM-dd')- interval '5 month' 
 order by create_time desc 
  • 1
  • 2
  • 3
  • 4

在这里插入图片描述

获取5日内数据

select create_time
 from xj_check as n
 where  n.create_time>=to_timestamp(substring(to_char(now(),'yyyy-MM-dd hh24:MI:ss') FROM 1 FOR 10),'yyyy-MM-dd')- interval '5 day' 
 order by create_time desc 
  • 1
  • 2
  • 3
  • 4

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/495619
推荐阅读
相关标签
  

闽ICP备14008679号