首页 > 数据库技术 > 详细

Oracle 查询时间在当天的数据

时间:2014-12-27 23:03:07      阅读:566      评论:0      收藏:0      [点我收藏+]

要实现这个功能需要用到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)

  

Oracle 查询时间在当天的数据

原文:http://www.cnblogs.com/simeone/p/4189264.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!