好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > oracle獲取上一旬的開始時間和結束時間的實現函數

oracle獲取上一旬的開始時間和結束時間的實現函數

熱門標簽:美圖秀秀地圖標注 開封智能外呼系統廠家 征服眼公司地圖標注 word地圖標注方向 百度地圖標注素材 外呼線路外顯本地號碼 阿爾巴尼亞地圖標注app 人工智能地圖標注自己能做嗎 征服者火車站地圖標注
復制代碼 代碼如下:

-- 獲取上旬開始時間
create or replace function fd_lastxunstart(rq in date) return string is
refstr varchar2(50);
v_rq date;
begin
--獲取上一旬的日期
v_rq := trunc(rq);
select case decode(trunc((to_char(v_rq, 'dd') - 1) / 10),
0,
'上旬',
1,
'中旬',
'下旬')
when '上旬' then --返回上個月的下旬
to_char(add_months(v_rq, -1), 'yyyyMM') || '21'
when '中旬' then
to_char(v_rq, 'yyyymm') || '01' else 
to_char(v_rq, 'yyyymm') || '11'
end
into refstr
from dual;
return refstr;
end fd_lastxunstart;

-- 這個返回的是:上旬的開始日期
select sysdate from dual;
select fd_lastxunstart(sysdate) from dual;
select fd_lastxunstart(to_date('20130305','yyyymmdd')) from dual;
select fd_lastxunstart(to_date('20130311','yyyymmdd')) from dual;
select fd_lastxunstart(to_date('20130325','yyyymmdd')) from dual;

-- 執行結果為: 2013/9/5 12:08:39、20130821、20130221、20130301、20130311

---- 獲取上一旬的結束日期
-- 傳遞進去 一個 date 類型的值,返回一個varchar類型的上旬結束日期
create or replace function fd_lastxunend(rq in date) return string is
refstr varchar2(50);
v_rq date;
begin
--獲取上一旬的日期
v_rq := trunc(rq);
select case decode(trunc((to_char(v_rq, 'dd') - 1) / 10),
0,
'上旬',
1,
'中旬',
'下旬')
when '上旬' then --返回上個月的最后1天
--chr(39) 這個是加引號
to_char(last_day(add_months(v_rq, -1)) + 1 - 1 / 24 / 60 / 60,
'yyyymmdd')
when '中旬' then
to_char(v_rq, 'yyyymm') || '10' else 
to_char(v_rq, 'yyyymm') || '20'
end
into refstr
from dual;
return refstr;
end fd_lastxunend;

-- 這個獲取的是:上旬的結束日期
select fd_lastxunend(sysdate) from dual;
select fd_lastxunend(to_date('20130305','yyyymmdd')) from dual;
select fd_lastxunend(to_date('20130311','yyyymmdd')) from dual;
select fd_lastxunend(to_date('20130315','yyyymmdd')) from dual;
select fd_lastxunend(to_date('20130221','yyyymmdd')) from dual;

--執行結果:20130831、20130228、20130310、20130310、20130220

-- 觀察 1 / 24 / 60 / 60 的作用 這個是一秒
select last_day(add_months(trunc(sysdate), -1)) + 1 - 1 / 24 / 60 / 60
from dual;
select last_day(add_months(trunc(sysdate), -1)) from dual;
select last_day(add_months(trunc(sysdate), -1)) + 1 from dual;
-- 執行結果:2013/8/31 23:59:59、2013/8/31、2013/9/1
您可能感興趣的文章:
  • oracle中得到一條SQL語句的執行時間的兩種方式
  • oracle 日期時間函數使用總結
  • oracle日期時間型timestamp的深入理解
  • Oracle時間日期操作方法小結
  • oracle 時間格式的調整
  • Oracle關于時間/日期的操作
  • 修改計算機名或IP后Oracle10g服務無法啟動的解決方法
  • 計算機名稱修改后Oracle不能正常啟動問題分析及解決
  • Oracle通過時間(分鐘)計算有幾天幾小時幾分鐘的方法

標簽:淮南 孝感 海北 葫蘆島 宜春 六安 泰安 酒泉

巨人網絡通訊聲明:本文標題《oracle獲取上一旬的開始時間和結束時間的實現函數》,本文關鍵詞  oracle,獲取,上一,旬,的,開始,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《oracle獲取上一旬的開始時間和結束時間的實現函數》相關的同類信息!
  • 本頁收集關于oracle獲取上一旬的開始時間和結束時間的實現函數的相關信息資訊供網民參考!
  • 推薦文章