oracle年月日时分秒日期换算

计算小时,分,秒,毫秒      

    select      
     Days,      
     A,      
     TRUNC(A*24) Hours,      
     TRUNC(A*24*60 - 60*TRUNC(A*24)) Minutes,      
     TRUNC(A*24*60*60 - 60*TRUNC(A*24*60)) Seconds,      
     TRUNC(A*24*60*60*100 - 100*TRUNC(A*24*60*60)) mSeconds      
    from      
    (      
     select      
     trunc(sysdate) Days,      
     sysdate - trunc(sysdate) A      
     from dual      
   )    

oracle日期计算换算

  floor((date2-date1) /365) 作为年      
   floor((date2-date1, 365) /30) 作为月      
   d(mod(date2-date1, 365), 30)作为日.
当前时间减去7分钟的时间 
select sysdate,sysdate - interval ’7’ MINUTE from dual 
当前时间减去7小时的时间 
select sysdate - interval ’7’ hour from dual 
当前时间减去7天的时间 
select sysdate - interval ’7’ day from dual 
当前时间减去7月的时间 
select sysdate,sysdate - interval ’7’ month from dual 
当前时间减去7年的时间 
select sysdate,sysdate - interval ’7’ year from dual 
时间间隔乘以一个数字 
select sysdate,sysdate - 8 *interval ’2’ hour from dual

日期天换算为秒

select (sysdate-to_date('2003-12-03 12:55:45','yyyy-mm-dd hh24:mi:ss'))*24*60*60 from dual 


 

猜你喜欢

转载自blog.csdn.net/qq_35029061/article/details/82765553