oracle学习笔记
根据系统时间获取上周一时间并转化为number create or replace function getUpMonday return number is Result number; begin declare cursor MyCursor is select to_number(to_date(to_char(d.surmon,'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss') - to_date('1970-01-01 8:0:0', 'yyyy-mm-dd hh24:mi:ss'))*24*60*60*1000 from ( SELECT case to_number(to_char(to_date(to_char(sysdate,'yyyy-mm-dd'),'yyyy-mm-dd hh24:mi:ss'),'D')) when 7 then to_date(to_char(sysdate,'yyyy-mm-dd'),'yyyy-mm-dd hh24:mi:ss')-12 when 6 the n to_date(to_char(sysdate,'yyyy-mm-dd'),'yyyy-mm-dd hh24:mi:ss')-11 when 5 then to_date(to_char(sysdate,'yyyy-mm-dd'),'yyyy-mm-dd hh24:mi:ss')-10 when 4 then to_date(to_char(sysdate,'yyyy-mm-dd'),'yyyy-mm-dd hh24:mi:ss')-9 when 3 then to_date(to_char(sysdate,'yyyy-mm-dd'),'yyyy-mm-dd hh24:mi:ss')-8 when 2 then to_date(to_char(sysdate,'yyyy-mm-dd'),'yyyy-mm-dd hh24:mi:ss') else to_date(to_char(sysdate,'yyyy-MM-dd'),'yyyy-mm-dd hh24:mi:ss')-13 end as surmon FROM DUAL ) d; begin open MyCursor; fetch MyCursor into Result; close MyCursor; end; return(Result); end;
下载地址
用户评论