oracle獲取當前時間順延指定工作日的日期

2021-08-21 08:13:46 字數 1195 閱讀 2532

1、建立節假日表,包含週六日

2、利用迭代,寫oracle function

create or replace function func_getbusideferdate(startdate date,deferday number)

return date

/*返回推遲number個工作日的日期,不包含當前日期*/

isenddate date :=startdate+deferday;

holiday_num number:=0;

tempdate date;

begin

select nvl(count(1),0) into holiday_num from ea_deadline_holiday_config t

where t.vacation_date between to_char(startdate+1, 'yyyymmdd') and to_char(enddate, 'yyyymmdd');

if holiday_num!=0 then

enddate :=func_getbusideferdate(enddate,holiday_num);/*這裡迭代,順延的日期如果還有節假期繼續計算*/

end if;

return enddate;

end;

3、執行效果

oracle獲取當前時間

select to char sysdate,yyyy mm dd hh24 mi ss from dual select to char sysdate,yyyy mm dd hh24 mm ss from dual 容易出錯 elect to char sysdate,yyyy mm dd hh...

oracle獲取當前時間

用法to char sysdate,yyyy mm dd hh24 mi ss 把時間變成字串 用法to date 2015 08 12 15 53 37 yyyy mm dd hh24 mi ss 把字串變成時間 用法to number把字串變成數字 用法trunc負責擷取數字或者字串 selec...

獲取當前時間

獲取日期 時間 datetime.now.tostring 2008 9 4 20 02 10 datetime.now.tolocaltime tostring 2008 9 4 20 12 12 獲取日期 datetime.now.tolongdatestring tostring 2008年9...