Oracle 查詢時間在當天的數據


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

select trunc(sysdate) from dual  --2021-11-03  今天的日期為2021-11-03

select  trunc(sysdate,  'mm' )    from    dual   --2021-11-01    返回當月第一天.
select  trunc(sysdate, 'yy' from  dual   --2021-01-01       返回當年第一天
select  trunc(sysdate, 'dd' from  dual   --2021-11-03    返回當前年月日
select  trunc(sysdate, 'yyyy' from  dual   --2021-01-01   返回當年第一天
select  trunc(sysdate, 'd' from  dual   --2021-10-31 (星期天)返回當前星期的第一天
select  trunc(sysdate,  'hh' from  dual    --2021-11-03 11:00:00   當前時間為11:小時  
select  trunc(sysdate,  'mi' from  dual   --2021-11-03 11:39:00   TRUNC()函數沒有秒的精,時分
 
查詢時間在當天的數據就要用到trunc的第一種使用
select * from 表名 where trunc(UPDATE_TIME)=trunc(sysdate)


免責聲明!

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



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