您好,登錄后才能下訂單哦!
顯示距離當(dāng)前時(shí)間的跨度
-- 計(jì)算時(shí)間跨度:返回值為X天y時(shí)z分
declare
ln_day_count number(10);
ln_hour_count number(10);
ln_min_count number(10);
ls_time_sent_last varchar2(20) := '2015-06-07 08:40:20';
ls_timespan varchar2(100) := '';
begin
-- 計(jì)算天數(shù)
select floor(sysdate - To_date(ls_time_sent_last, 'yyyy-mm-dd hh34-mi-ss')) into ln_day_count FROM dual;
if ln_day_count != 0 then
ls_timespan := to_char(ln_day_count) || '天';
dbms_output.put_line(ls_timespan);
end if;
-- 計(jì)算小時(shí)數(shù)
select mod(floor(((sysdate - To_date(ls_time_sent_last, 'yyyy-mm-dd hh34-mi-ss'))) * 24),24) into ln_hour_count FROM dual;
if ln_hour_count != 0 then
ls_timespan := ls_timespan || to_char(ln_hour_count) || '時(shí)';
dbms_output.put_line(ls_timespan);
end if;
-- 計(jì)算分鐘數(shù)
select mod(mod(floor(((sysdate - To_date(ls_time_sent_last, 'yyyy-mm-dd hh34-mi-ss'))) * 24 * 60),24*60),60) into ln_min_count FROM dual;
if ln_min_count != 0 then
ls_timespan := ls_timespan || to_char(ln_min_count) || '分';
dbms_output.put_line(ls_timespan);
end if;
end;
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。