oracle计算两日期相差多少秒,分钟,小时,天,周,月,年

--计算两个时间差相差多少秒
select ceil((sysdate-t.transdate)* 24 * 60 * 60),t.transdate,sysdate from esc_trans_log t
--计算两个时间差相差多少分
select ceil((sysdate-t.transdate)* 24 * 60),t.transdate,sysdate from esc_trans_log t
--计算两个时间差相差多少小时
select ceil((sysdate-t.transdate)* 24),t.transdate,sysdate from esc_trans_log t
--计算两个时间差相差多少天
select ceil(sysdate-t.transdate),t.transdate,sysdate from esc_trans_log t
--计算两个时间差相差多少月
select trunc(months_between(sysdate,t.transdate)) from esc_trans_log t
--计算两个时间差相差多少年
select trunc(months_between(sysdate,t.transdate)/12) from esc_trans_log t

posted @ 2018-12-11 10:24  小熊园地  阅读(7499)  评论(1编辑  收藏  举报