Oracle   发布时间:2022-05-17  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了oracle 取当前日期时间的前一天前一小时前一分钟前一秒大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

地址:http://wentao365.iteye.com/blog/779492



SELECT '当前时间' title,TO_CHAR(sysdate,'yyyy-mm-dd hh24:mi:ss') TIME
  FROM DUAL --当前时间
union all
SELECT '前一天前一小时前一分钟前一秒' title,TO_CHAR(sysdate - 1 - 1 / 24 - 1 / 24 / 60 - 1 / 24 / 60 / 60,'yyyy-mm-dd hh24:mi:ss') TIME
  FROM DUAL
union all
SELECT '一分钟前' title,TO_CHAR(sysdate - 1 / 24 / 60,'yyyy-mm-dd hh24:mi:ss')
  FROM DUAL


某个时间之后571天的时间是:
SELEct to_date('2009-11-16 14:33:27','yyyy-MM-dd HH24:mi:ss') + 571 from dual



引用
sysdate+(5/24/60/60) 在系统时间基础上延迟5秒
sysdate+5/24/60 在系统时间基础上延迟5分钟
sysdate+5/24 在系统时间基础上延迟5小时
sysdate+5 在系统时间基础上延迟5天
add_months(sysdate,-5) 在系统时间基础上延迟5月
add_months(sysdate,-5*12) 在系统时间基础上延迟5年


查询10分钟前的记录
Java代码  收藏代码

    SELEct * from sq_leavemessage m where sysdate-m.createtime<=10/60/24   



1天前创建的产品
Java代码  收藏代码

    SELEct pv.create_time from product_version pv where round(to_number(sysdate-pv.create_timE))<=1  



6小时前创建的产品
Java代码  收藏代码

    SELEct pv.create_time from product_version pv where round(to_number(sysdate-pv.create_timE)*24)<=6  



1分钟前创建的产品
Java代码  收藏代码

    SELEct pv.create_time from product_version pv where round(to_number(sysdate-pv.create_timE)*1440)<=1  
 
 
 
 
 
 
 
 
 
 
<a target=_blank href="http://blog.csdn.net/z69183787/article/details/22409771" style="text-decoration: none; color: rgb(0,0); Font-family: "microsoft yahei"; Font-size: 18px; Font-weight: bold;">Oracle sysdate 时间加减</a>
<p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,69,69); Font-family: tahoma,Helvetica,arial; Font-size: 14px; line-height: 14px;">加法</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,arial; Font-size: 14px; line-height: 14px;"></p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,arial; Font-size: 14px; line-height: 14px;">SELEct sysdate,add_months(sysdate,12) from dual;--加1年</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,1) from dual;--加1月</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,to_char(sysdate+7,'yyyy-mm-dd HH24:MI:SS') from dual;--加1星期</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,TO_CHAR(sysdate+1,'yyyy-mm-dd HH24:MI:SS') from dual;--加1天</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,TO_CHAR(sysdate+1/24,'yyyy-mm-dd HH24:MI:SS') from dual;--加1小时</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,TO_CHAR(sysdate+1/24/60,'yyyy-mm-dd HH24:MI:SS') from dual;--加1分钟</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,TO_CHAR(sysdate+1/24/60/60,'yyyy-mm-dd HH24:MI:SS') from dual; --加1秒</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,arial; Font-size: 14px; line-height: 14px;">减法</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,-12) from dual;--减1年</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,-1) from dual;--减1月</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,TO_CHAR(sysdate-7,'yyyy-mm-dd HH24:MI:SS') from dual;--减1星期</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,TO_CHAR(sysdate-1,'yyyy-mm-dd HH24:MI:SS') from dual;--减1天</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,TO_CHAR(sysdate-1/24,'yyyy-mm-dd HH24:MI:SS') from dual;--减1小时</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,TO_CHAR(sysdate-1/24/60,'yyyy-mm-dd HH24:MI:SS') from dual;--减1分钟</p><p style="margin-top: 0px; @R_404_5553@-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(69,TO_CHAR(sysdate-1/24/60/60,'yyyy-mm-dd HH24:MI:SS') from dual; --减1秒</p>

大佬总结

以上是大佬教程为你收集整理的oracle 取当前日期时间的前一天前一小时前一分钟前一秒全部内容,希望文章能够帮你解决oracle 取当前日期时间的前一天前一小时前一分钟前一秒所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: