Oracle 查詢時間在當天的數據

要實現這個功能須要用到trunc這個函數對時間的操做

select trunc(sysdate) from dual  --2014-12-27  今天的日期爲2014-12-27
select trunc(sysdate, 'mm')   from   dual  --2014-12-1    返回當月第一天.
select trunc(sysdate,'yy') from dual  --2014-1-1       返回當年第一天
select trunc(sysdate,'dd') from dual  --2014-3-18    返回當前年月日
select trunc(sysdate,'yyyy') from dual  --2014-1-1   返回當年第一天
select trunc(sysdate,'d') from dual  --2014-12-21 (星期天)返回當前星期的第一天
select trunc(sysdate, 'hh') from dual   --2014-12-27 22:00:00   當前時間爲14:41
select trunc(sysdate, 'mi') from dual  --2014-12-27 22:17:00   TRUNC()函數沒有秒的精
查詢時間在當天的數據就要用到trunc的第一種使用

select * from T_BASE where trunc(BASE_TIME)=trunc(sysdate)
相關文章
相關標籤/搜索