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