---
title: "Oracle中求出本星期第一天和第七天的日期"
author: "ccfangle"
date: "2015-03-03T10:17:31Z"
tags: []
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2015-03-03T10:17:31Z"
id: 2188169
url: "https://ccfangle.iteye.com/blog/2188169"
---

&lt;1&gt;西方应用是周日是first day，中国人思维则为，周日是最后一天。其实，只需要计算到周一，就可直接获得周日。

&lt;2&gt;应用实例

--Sunday

select to\_date(next\_day(to\_date('2015-02-09 22:00:00', 'yyyy-mm-dd hh24:mi:ss') - 7, 2)) 周一,  
to\_date(next\_day(to\_date('2015-02-09 22:00:00', 'yyyy-mm-dd hh24:mi:ss') - 7, 2))+6 Sunday  
 from dual;

--Saturday

select to\_date(next\_day(to\_date('2015-02-14 22:00:00', 'yyyy-mm-dd hh24:mi:ss') - 7, 2)) 周一,  
to\_date(next\_day(to\_date('2015-02-14 22:00:00', 'yyyy-mm-dd hh24:mi:ss') - 7, 2))+6  Sunday  
  from dual;

--Sunday

select to\_date(next\_day(to\_date('2015-02-15 22:00:00', 'yyyy-mm-dd hh24:mi:ss') - 7, 2)) 周一,  
to\_date(next\_day(to\_date('2015-02-15 22:00:00', 'yyyy-mm-dd hh24:mi:ss') - 7, 2))+6  Sunday  
from dual;