Oracle取某时间段的数据


Oracle取某时间段的数据:

sysdate+1是加一天,sysdate+/-(1/48)就是加/减 半个小时

select count(*) from table_name where table_name.date between to_char(sysdate-1/48,'yyyymmdd HH:mi') and sysdate

其中date为你要统计的字段名字

table_name为表的名字

to_char是一个日期函数 to_char(sysdate,'yyyymmdd HH:mi') 为截取到分钟,对应的to_char(sysdate,'yyyymmdd HH')为截取到小时。to_char(sysdate,'yyyymm')为截取到月份,

相关内容