1. 程式人生 > >oracle --sql--查詢日期區間的資料

oracle --sql--查詢日期區間的資料

兩種方法

兩種情況:
1:查詢給定時間在開始時間列與結束時間列範圍中資料;
2:查詢日期列在開始時間列與結束時間列範圍中資料;

第一種:<,>, <= , >=

  select * from 表名 where 日期列 >= to_date('2015-10-20 00:00:00','yyyy-mm-dd hh24:mi:ss') and t.日期列 <= to_date('2015-10-20 23:59:59','yyyy-mm-dd hh24:mi:ss')

第二種 between and

select * from 表名 where 日期列 between to_date('2015-10-20 00:00:00'
,'yyyy-mm-dd hh24:mi:ss')and to_date('2015-10-20 23:59:59','yyyy-mm-dd hh24:mi:ss')