婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > Oracle 獲取上周一到周末日期的查詢sql語句

Oracle 獲取上周一到周末日期的查詢sql語句

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

-- Oracle 取上周一到周末的sql

-- 這樣取的是 在一周內(nèi)第幾天,是以周日為開始的
select to_char(to_date('20130906','yyyymmdd'),'d') from dual;
--結(jié)果:6 注釋:2013.09.06是周五,為本周的第六天

select to_char(sysdate+(2-to_char(sysdate,'d'))-7,'yyyymmdd') from dual;---上周一
select to_char(sysdate+(2-to_char(sysdate,'d'))-1,'yyyymmdd') from dual;---上周日

-- 一個更簡單的寫法 , 返回date類型
select trunc(sysdate,'iw') - 7 from dual;---上周一
select trunc(sysdate,'iw') - 1 from dual;--上周日

-- 這樣查出來是本周一
select trunc(sysdate,'iw') from dual;

select trunc(to_date('20130915','yyyymmdd'),'iw') from dual;
-- 結(jié)果:2013/9/9 注釋:20130915 為周日

-- 返回char類型
select to_char(trunc(sysdate,'iw') - 7,'yyyymmdd') from dual;--上周一
select to_char(trunc(sysdate,'iw') - 1,'yyyymmdd') from dual;--上周日

-- 獲取上周一的函數(shù)
create or replace function fun_acc_getlastweekstart(systemdate in date)
return varchar2 is
result_str varchar2(15);
begin
select to_char(trunc(systemdate, 'iw') - 7, 'yyyymmdd')
into result_str
from dual;
return result_str;
end fun_acc_getlastweekstart;

-- 獲取上周日的函數(shù)
create or replace function fun_acc_getlastweekend(systemdate in date) return varchar2 is
result_str varchar2(15);
begin
select to_char(trunc(systemdate, 'iw') - 1, 'yyyymmdd')
into result_str
from dual;
return result_str;
end fun_acc_getlastweekend;

-- 測試這個函數(shù)
select fun_acc_getlastweekstart(sysdate) from dual;
select fun_acc_getlastweekend(sysdate) from dual;
select fun_acc_getlastweekstart(to_date('20130915','yyyymmdd')) from dual;
select fun_acc_getlastweekend(to_date('20130915','yyyymmdd')) from dual;
--查詢結(jié)果:20130826、20130901、20130902、20130908
-- 注:
select sysdate from dual;
--查詢結(jié)果:2013/9/6 9:45:14
您可能感興趣的文章:
  • oracle日期時間型timestamp的深入理解
  • Oracle 函數(shù)大全[字符串函數(shù),數(shù)學(xué)函數(shù),日期函數(shù)]
  • Oracle插入日期數(shù)據(jù)常見的2個問題和解決方法
  • oracle查看當(dāng)前日期是第幾個星期的方法
  • Oracle to_char 日期轉(zhuǎn)換字符串語句分享
  • 詳解oracle 日期格式(總結(jié))
  • oracle 日期時間函數(shù)使用總結(jié)
  • ORACLE 毫秒與日期的相互轉(zhuǎn)換示例
  • oracle 日期函數(shù)集合(集中版本)
  • oracle日期分組查詢的完整實例

標(biāo)簽:泰安 海北 宜春 六安 孝感 葫蘆島 酒泉 淮南

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Oracle 獲取上周一到周末日期的查詢sql語句》,本文關(guān)鍵詞  Oracle,獲取,上周,一到,周末,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Oracle 獲取上周一到周末日期的查詢sql語句》相關(guān)的同類信息!
  • 本頁收集關(guān)于Oracle 獲取上周一到周末日期的查詢sql語句的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 金塔县| 朝阳县| 齐齐哈尔市| 长岛县| 陇西县| 米易县| 合江县| 泰顺县| 双城市| 垫江县| 泰州市| 永寿县| 英吉沙县| 廉江市| 临潭县| 红安县| 平武县| 中宁县| 手游| 忻州市| 台州市| 舟山市| 康平县| 霍山县| 开原市| 行唐县| 镇远县| 永安市| 高邑县| 保靖县| 平乡县| 荥阳市| 左权县| 揭阳市| 黄龙县| 玛曲县| 惠水县| 湘潭市| 赫章县| 泽库县| 宁远县|