oracle查询今日、昨日、本周、本季度的数据

Oracle 查询今日、昨日、本周、本月和本季度的所有记录
  1. 字段类型为date

今日
 select * from 表名 where to_char(字段名,'dd')=to_char(sysdate,'dd')

昨日

select * from  表名 where to_char(字段名,'dd')= to_char(sysdate-1,'dd')
本周 
 select * from 表名 where to_char(字段名,'iw')=to_char(sysdate,'iw') 
本月 
 select * from 表名 where to_char(字段名,'mm')=to_char(sysdate,'mm') 
本季度 
 select * from 表名 where to_char(字段名,'q')=to_char(sysdate,'q')

猜你喜欢

转载自blog.csdn.net/qq_41901887/article/details/80077075