---
title: "oracle当月、当年、本周数据"
author: "Jophy"
date: "2009-02-23T15:40:06Z"
tags: []
slug: "oracle"
draft: false
lastmod: "2009-04-23T11:02:37Z"
id: 337321
url: "https://jophy.iteye.com/blog/337321"
---

当月数据
```sql
select * from table t 
where t.create_time >=TRUNC(SYSDATE, 'MM') 
and t.create_time<=last_day(SYSDATE)
```

当年数据
```sql
select * from table t
where t.create_time >=trunc(sysdate,'YYYY') 
and t.create_time<=add_months(trunc(sysdate,'YYYY'),12)-1
```

本周（国外周日为一个星期第一天）
```sql

where t.create_time >=trunc(sysdate,'day')+1 and t.create_time<=trunc(sysdate,'day')+6 

```

本周（国内周一为一个星期第一天）
```sql

where t.create_time >=trunc(next_day(sysdate-8,1)+1) and t.create_time<=trunc(next_day(sysdate-8,1)+7)+1

```