Oracle計算時間SQL

2021-06-12 11:24:07 字數 494 閱讀 5307

select extract(day

from(to_date('20130210000000', 'yyyymmddhh24miss') - sysdate)

day(9) to second) 天,

extract(hour

from(to_date('20130210000000', 'yyyymmddhh24miss') - sysdate)

day(9) to second) 時,

extract(minute

from(to_date('20130210000000', 'yyyymmddhh24miss') - sysdate)

day(9) to second) 分鐘,

extract(second

from(to_date('20130210000000', 'yyyymmddhh24miss') - sysdate)

day(9) to second) 秒

from dual

sql 時間計算

兩個時間之差的合計 declare i int set i datediff ms,getdate rand 24,getdate select convert varchar 10 i 86400000 days convert varchar 10 i 86400000 3600000 hour...

oracle 計算時間間距

months between months between x,y 用於計算x和y之間有幾個月。如果x在日曆中比y早,那麼months between 就返回乙個負數。當x 和 y 之間的月份之差不是整月的時候,可以採用小數表示,例如 select months between 25 may 200...

Oracle常用SQL時間函式

1 查詢當前日期和時間 select sysdate from dual 2 查詢本月最後一天 select last day sysdate from dual 3 查詢前後多少月 select add months sysdate,24 from dual select next day sys...