oracle中将datetime字段的间隔处理显示成几天几小时几分钟几秒进行显示
--numtodsinterval(<x>,<c>) ,x是一个数字,c是一个字符串,
表明x的单位,这个函数把x转为interval day to second数据类型
常用的单位有 ('day','hour','minute','second')
示例:
select to_char(extract(day from numtodsinterval(F_DT_CHUKRQJSJ - F_DT_RUKRQJSJ,'day')))||'天',
to_char(extract(hour from numtodsinterval(F_DT_CHUKRQJSJ - F_DT_RUKRQJSJ,'day')))||'小时',
to_char(extract(minute from numtodsinterval(F_DT_CHUKRQJSJ - F_DT_RUKRQJSJ,'day')))||'分钟',
to_char(round(to_number (extract(second from numtodsinterval(F_DT_CHUKRQJSJ - F_DT_RUKRQJSJ,'day')))))||'秒'
from B_TXF_CHEDXFYSSJ where F_DT_CHUKRQJSJ = to_date('2018-07-13 17:24:21','yyyy-MM-dd hh24:mi:ss');