|
- with t1 as
- (select (to_date('2016-03-31 12:09:29', 'yyyy-mm-dd hh24:mi:ss') -
- to_date('2016-03-16 18:03:02', 'yyyy-mm-dd hh24:mi:ss')) * 24 * 60 * 60 as parsec
- from dual),
- t2 as
- (select trunc(parsec / (24 * 60 * 60)) || '天' as days,
- trunc((parsec - (trunc(parsec / (24 * 60 * 60)) * (24 * 60 * 60))) /
- (60 * 60)) || '小时' as hours,
- trunc((parsec - trunc(parsec / (24 * 60 * 60)) * (24 * 60 * 60) -
- trunc((parsec -
- (trunc(parsec / (24 * 60 * 60)) * (24 * 60 * 60))) /
- (60 * 60)) * (60 * 60)) / 60) || '分' as minutes,
- (parsec - trunc(parsec / (24 * 60 * 60)) * (24 * 60 * 60) -
- trunc((parsec - (trunc(parsec / (24 * 60 * 60)) * (24 * 60 * 60))) /
- (60 * 60)) * (60 * 60) -
- trunc((parsec - trunc(parsec / (24 * 60 * 60)) * (24 * 60 * 60) -
- trunc((parsec -
- (trunc(parsec / (24 * 60 * 60)) * (24 * 60 * 60))) /
- (60 * 60)) * (60 * 60)) / 60) * 60) || '秒' as seconds
- from t1)
- select days || hours || minutes || seconds from t2
复制代码
|
|