# 在 Access 查詢中使用日期作為準則的範例

## 於準則中使用目前日期的範例

Date()

Date()-1

Date() + 1

DatePart("ww", [SalesDate]) = DatePart("ww", Date()) and Year( [SalesDate]) = Year(Date())

Year([SalesDate])* 53 + DatePart("ww", [SalesDate]) = Year(Date())* 53 + DatePart("ww", Date()) - 1

Year([SalesDate])* 53+DatePart("ww", [SalesDate]) = Year(Date())* 53+DatePart("ww", Date()) + 1

Between Date() and Date()-6

Year([SalesDate]) = Year(Now()) And Month([SalesDate]) = Month(Now())

Year([SalesDate])* 12 + DatePart("m", [SalesDate]) = Year(Date())* 12 + DatePart("m", Date()) - 1

Year([SalesDate])* 12 + DatePart("m", [SalesDate]) = Year(Date())* 12 + DatePart("m", Date()) + 1

Between Date( ) And DateAdd("M", -1, Date( ))

Year([SalesDate]) = Year(Now()) And DatePart("q", Date()) = DatePart("q", Now())

Year([SalesDate])*4+DatePart("q",[SalesDate]) = Year(Date())*4+DatePart("q",Date())- 1

Year([SalesDate])*4+DatePart("q",[SalesDate]) = Year(Date())*4+DatePart("q",Date())+1

Year([SalesDate]) = Year(Date())

Year([SalesDate]) = Year(Date()) - 1

Year([SalesDate]) = Year(Date()) + 1

Year([SalesDate]) = Year(Date()) and Month([SalesDate]) <= Month(Date()) and Day([SalesDate]) <= Day (Date())

< Date()

> Date()

## 使用目前日期以外之日期或日期範圍的範例

#2/2/2012#

Not #2/2/2012#

< #2/2/2012#

> #2/2/2012#

>#2/2/2012# and <#2/4/2012#

<#2/2/2012# or >#2/4/2012#

#2/2/2012# or #2/3/2012#

In (#2/1/2012#, #3/1/2012#, #4/1/2012#)

DatePart("m", [SalesDate]) = 12

DatePart("q", [SalesDate]) = 1

Is Null

Is Not Null

Is Null

Is Not Null

×