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)

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM