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

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

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

熱門標(biāo)簽:word地圖標(biāo)注方向 征服眼公司地圖標(biāo)注 美圖秀秀地圖標(biāo)注 開封智能外呼系統(tǒng)廠家 人工智能地圖標(biāo)注自己能做嗎 百度地圖標(biāo)注素材 外呼線路外顯本地號(hà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;---上周日

-- 一個(gè)更簡(jiǎn)單的寫法 , 返回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;

-- 測(cè)試這個(gè)函數(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日期時(shí)間型timestamp的深入理解
  • Oracle 函數(shù)大全[字符串函數(shù),數(shù)學(xué)函數(shù),日期函數(shù)]
  • Oracle插入日期數(shù)據(jù)常見的2個(gè)問題和解決方法
  • oracle查看當(dāng)前日期是第幾個(gè)星期的方法
  • Oracle to_char 日期轉(zhuǎn)換字符串語句分享
  • 詳解oracle 日期格式(總結(jié))
  • oracle 日期時(shí)間函數(shù)使用總結(jié)
  • ORACLE 毫秒與日期的相互轉(zhuǎn)換示例
  • oracle 日期函數(shù)集合(集中版本)
  • oracle日期分組查詢的完整實(shí)例

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

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Oracle 獲取上周一到周末日期的查詢sql語句》,本文關(guān)鍵詞  Oracle,獲取,上周,一到,周末,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(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)民參考!
  • 推薦文章
    主站蜘蛛池模板: 浠水县| 永仁县| 天津市| 城步| 建湖县| 昭通市| 长治县| 宝坻区| 米易县| 江山市| 玉树县| 宜黄县| 綦江县| 临城县| 江北区| 柳河县| 武平县| 定陶县| 邛崃市| 通许县| 鲁山县| 灵宝市| 砀山县| 蛟河市| 遂昌县| 双鸭山市| 长岛县| 德化县| 喀喇沁旗| 张掖市| 东乡县| 陵水| 五原县| 建水县| 定安县| 屯门区| 贺州市| 右玉县| 玉门市| 丽江市| 太康县|