Oracle计算时间函数(numtodsinterval、numtoyminterval)

numtodsinterval(<数字>,<字符串>)

字符串包含('day','hour','minute','second')

 

select sysdate,sysdate+numtodsinterval(3,'day') as res from dual; --取三天后的时间

 

select sysdate,sysdate+numtodsinterval(3,'hour') as res from dual;--取三小时后的时间

 

select sysdate,sysdate+numtodsinterval(3,'minute') as res from dual; --取三分钟后的时间  

 

select sysdate,sysdate+3/24 as res from dual --取三分钟后的时间  需换算 


select sysdate,sysdate+numtodsinterval(3,'second') as res from dual; --取三秒后的时间

 

numtodsinterval(<数字>,<字符串>)

字符串包含('year','month')

 

select sysdate,sysdate+numtoyminterval(3,'year') as res from dual; --取三年后的时间


select sysdate,sysdate+numtoyminterval(-3,'month') as res from dual;--取三月前的时间

posted on 2019-08-27 17:22  帅阿红  阅读(1419)  评论(0编辑  收藏  举报