0% found this document useful (0 votes)
35 views31 pages

To Include Items That ... Use This Criteria Query Result

This document provides examples of criteria that can be used to query items based on date fields, including filtering by today's date, yesterday's date, tomorrow's date, dates within the current, previous or following week, dates within the last 7 days, dates within the current, previous or next month, dates within the last 30-31 days, and dates within the current quarter. Each criteria is accompanied by an explanation of what items would be returned if run on a sample date of February 2nd, 2012.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views31 pages

To Include Items That ... Use This Criteria Query Result

This document provides examples of criteria that can be used to query items based on date fields, including filtering by today's date, yesterday's date, tomorrow's date, dates within the current, previous or following week, dates within the last 7 days, dates within the current, previous or next month, dates within the last 30-31 days, and dates within the current quarter. Each criteria is accompanied by an explanation of what items would be returned if run on a sample date of February 2nd, 2012.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

To Use this criteria Query

include result
items that
...
Contain Date() Returns
today's items with
date a date of
today. If
today's
date is
2/2/2012,
you’ll see
items
where the
date field
is set to
Feb 2,
To Use this criteria Query
include result
items that
...
2012.
Contain Date()-1 Returns
yesterday' items with
s date yesterday’
s date. If
today's
date is
2/2/2012,
you’ll see
items for
Feb 1,
2012.
To Use this criteria Query
include result
items that
...
Contain Date() + 1 Returns
tomorrow' items with
s date tomorrow’
s date. If
today's
date is
Feb 2,
2012,
you’ll see
items for
Feb 3,
2012.
Contain DatePart("ww", [SalesDate]) = Returns
To Use this criteria Query
include result
items that
...
dates DatePart("ww", Date()) and items with
within the Year( [SalesDate]) = Year(Date()) dates
current during the
week current
week. A
week in
Access
starts on
Sunday
and ends
on
Saturday.
Contain Year([SalesDate])* 53 + DatePart("ww", Returns
To Use this criteria Query
include result
items that
...
dates [SalesDate]) = Year(Date())* 53 + items with
within the DatePart("ww", Date()) - 1 dates
previous during the
week last week.
A week in
Access
starts on
Sunday
and ends
on
Saturday.
Contain Year([SalesDate])* 53+DatePart("ww", Returns
dates [SalesDate]) = Year(Date())* items with
To Use this criteria Query
include result
items that
...
within the 53+DatePart("ww", Date()) + 1 dates
following during
week next week.
A week in
Access
starts on
Sunday
and ends
on
Saturday.
Contain a Between Date() and Date()-6 Returns
date items with
within the dates
To Use this criteria Query
include result
items that
...
last 7 days during the
last 7
days. If
today's
date is
2/2/2012,
you’ll see
items for
the period
Jan 24,
2012
through
Feb 2,
To Use this criteria Query
include result
items that
...
2012.
Contain a Year([SalesDate]) = Year(Now()) And Returns
date Month([SalesDate]) = Month(Now()) items with
within the dates in
current the
month current
month. If
today's
date is
2/2/2012,
you’ll see
items for
Feb 2012.
To Use this criteria Query
include result
items that
...
Contain a Year([SalesDate])* 12 + DatePart("m", Returns
date [SalesDate]) = Year(Date())* 12 + items with
within the DatePart("m", Date()) - 1 dates in
previous the
month previous
month. If
today's
date is
2/2/2012,
you’ll see
items for
Jan 2012.
Contain a Year([SalesDate])* 12 + DatePart("m", Returns
To Use this criteria Query
include result
items that
...
date [SalesDate]) = Year(Date())* 12 + items with
within the DatePart("m", Date()) + 1 dates in
next the next
month month. If
today's
date is
2/2/2012,
you’ll see
items for
Mar 2012.
Contain a Between Date( ) And DateAdd("M", -1, Returns a
date Date( )) month's
within the worth of
To Use this criteria Query
include result
items that
...
last 30 or items. If
31 days today's
date is
2/2/2012,
you’ll see
items for
the period
Jan 2,
2012 to
Feb 2,
2012.
Contain a Year([SalesDate]) = Year(Now()) And Returns
date DatePart("q", [SalesDate]) = DatePart("q", items for
To Use this criteria Query
include result
items that
...
within the Now()) the
current current
quarter quarter. If
today's
date is
2/2/2012,
you’ll see
items for
the first
quarter of
2012.
Contain a Year([SalesDate])*4+DatePart("q", Returns
date [SalesDate]) = items for
To Use this criteria Query
include result
items that
...
within the Year(Date())*4+DatePart("q",Date())- 1 the
previous previous
quarter quarter. If
today's
date is
2/2/2012,
you’ll see
items for
the last
quarter of
2011.
Contain a Year([SalesDate])*4+DatePart("q", Returns
date [SalesDate]) = items for
To Use this criteria Query
include result
items that
...
within the Year(Date())*4+DatePart("q",Date())+1 the next
next quarter. If
quarter today's
date is
2/2/2012,
you’ll see
items for
the
second
quarter of
2012.
Contain a Year([SalesDate]) = Year(Date()) Returns
date items for
To Use this criteria Query
include result
items that
...
within the the
current current
year year. If
today's
date is
2/2/2012,
you’ll see
items for
the year
2012.
Contain a Year([SalesDate]) = Year(Date()) - 1 Returns
date items for
within the the
To Use this criteria Query
include result
items that
...
previous previous
year year. If
today's
date is
2/2/2012,
you’ll see
items for
the year
2011.
Contain a Year([SalesDate]) = Year(Date()) + 1 Returns
date items with
within the next
next year year's
To Use this criteria Query
include result
items that
...
date. If
today's
date is
2/2/2012,
you’ll see
items for
the year
2013.
Contain a Year([SalesDate]) = Year(Date()) and Returns
date Month([SalesDate]) <= Month(Date()) and items with
between Day([SalesDate]) <= Day (Date()) dates
Jan 1 and between
today Jan 1 of
To Use this criteria Query
include result
items that
...
(year-to- the
date current
items) year and
today. If
today's
date is
2/2/2012,
you’ll see
items for
the period
Jan 1,
2012 to
2/2/2012.
To Use this criteria Query
include result
items that
...
Contain a < Date() Returns
date that items with
occurred dates
in the past before
today.
Contain a > Date() Returns
date that items with
occurs in dates
the future after
today.
Examples that work with a date or range of
dates other than the current date
To include Use this criteria Query result
items that ...
Exactly match a #2/2/2012# Returns only items with
date, such as a date of Feb 2, 2012.
2/2/2012
Do not match a Not #2/2/2012# Returns items with a
date, such as date other than Feb 2,
2/2/2012 2012.
Contain values < #2/2/2012# Returns items with a
before a certain date before Feb 2,
date, such as 2012.
2/2/2012
To include Use this criteria Query result
items that ...

To view items with a


date on or before Feb
2, 2012, use
the <= operator
instead of
the < operator.
Contain values > #2/2/2012# Returns items with a
after a certain date after Feb 2, 2012.
date, such as
To view items with a
2/2/2012
date on or after Feb 2,
2012, use
the >= operator
instead of
the > operator.
To include Use this criteria Query result
items that ...
Contain values >#2/2/2012# and Returns items with a
within a date <#2/4/2012# date between Feb 2,
range (between 2012 and Feb 4, 2012.
two dates) Note:  You can also use
the Between operator to filter for a range
of values, including the end points. For
example, Between #2/2/2012# and
#2/4/2012# is the same as >=#2/2/2012#
and <=#2/4/2012#.

Contain dates <#2/2/2012# or Returns items with a


outside a range >#2/4/2012# date before Feb 2, 2012
or after Feb 4, 2012.
Contain one of #2/2/2012# or #2/3/2012# Returns items with a
two dates, such date of either Feb 2,
as 2/2/2012 or 2012 or Feb 3, 2012.
2/3/2012
To include Use this criteria Query result
items that ...
Contain one or In (#2/1/2012#, Returns items with a
more of many #3/1/2012#, #4/1/2012#) date of Feb 1, 2012,
dates March 1, 2012, or April
1, 2012.
Contain a date DatePart("m", [SalesDate]) Returns items with a
within a specific = 12 date in December of
month any year.
(regardless of
year), such as
December
Contain a date DatePart("q", [SalesDate]) Returns items with a
within a specific =1 date in the first quarter
quarter of any year.
(regardless of
To include Use this criteria Query result
items that ...
year), such as
the first quarter
Filter for null (or Is Null Returns items where
missing) values the date has not been
entered.
Filter for non- Is Not Null Returns items where
null values the date has been
entered.
To include items that ... Use this criteria Query result

Contain today's date Date() Returns items with a date of today. If today's
date is 2/2/2012, you’ll see items where the
date field is set to Feb 2, 2012.

Contain yesterday's date Date()-1 Returns items with yesterday’s date. If


today's date is 2/2/2012, you’ll see items for
Feb 1, 2012.

Contain tomorrow's date Date() + 1 Returns items with tomorrow’s date. If


To include Use this criteria Query result
items that ...
today's date is Feb 2, 2012, you’ll see items
for Feb 3, 2012.

Contain dates within the DatePart("ww", [SalesDate]) = DatePart("ww", Returns items with dates during the current
current week Date()) and Year( [SalesDate]) = Year(Date()) week. A week in Access starts on Sunday and
ends on Saturday.

Contain dates within the Year([SalesDate])* 53 + DatePart("ww", Returns items with dates during the last
previous week [SalesDate]) = Year(Date())* 53 + DatePart("ww", week. A week in Access starts on Sunday and
Date()) - 1 ends on Saturday.

Contain dates within the Year([SalesDate])* 53+DatePart("ww", [SalesDate]) Returns items with dates during next week.
following week = Year(Date())* 53+DatePart("ww", Date()) + 1 A week in Access starts on Sunday and ends
on Saturday.

Contain a date within the last 7 Between Date() and Date()-6 Returns items with dates during the last 7
days days. If today's date is 2/2/2012, you’ll see
items for the period Jan 24, 2012 through
Feb 2, 2012.

Contain a date within the Year([SalesDate]) = Year(Now()) And Returns items with dates in the current
current month Month([SalesDate]) = Month(Now()) month. If today's date is 2/2/2012, you’ll see
items for Feb 2012.

Contain a date within the Year([SalesDate])* 12 + DatePart("m", [SalesDate]) Returns items with dates in the previous
previous month = Year(Date())* 12 + DatePart("m", Date()) - 1 month. If today's date is 2/2/2012, you’ll see
To include Use this criteria Query result
items that ...
items for Jan 2012.

Contain a date within the next Year([SalesDate])* 12 + DatePart("m", [SalesDate]) Returns items with dates in the next month.
month = Year(Date())* 12 + DatePart("m", Date()) + 1 If today's date is 2/2/2012, you’ll see items
for Mar 2012.

Contain a date within the last Between Date( ) And DateAdd("M", -1, Date( )) Returns a month's worth of items. If today's
30 or 31 days date is 2/2/2012, you’ll see items for the
period Jan 2, 2012 to Feb 2, 2012.

Contain a date within the Year([SalesDate]) = Year(Now()) And DatePart("q", Returns items for the current quarter. If
current quarter [SalesDate]) = DatePart("q", Now()) today's date is 2/2/2012, you’ll see items for
the first quarter of 2012.

Contain a date within the Year([SalesDate])*4+DatePart("q",[SalesDate]) = Returns items for the previous quarter. If
previous quarter Year(Date())*4+DatePart("q",Date())- 1 today's date is 2/2/2012, you’ll see items for
the last quarter of 2011.

Contain a date within the next Year([SalesDate])*4+DatePart("q",[SalesDate]) = Returns items for the next quarter. If today's
quarter Year(Date())*4+DatePart("q",Date())+1 date is 2/2/2012, you’ll see items for the
second quarter of 2012.

Contain a date within the Year([SalesDate]) = Year(Date()) Returns items for the current year. If today's
current year date is 2/2/2012, you’ll see items for the
year 2012.

Contain a date within the Year([SalesDate]) = Year(Date()) - 1 Returns items for the previous year. If
To include Use this criteria Query result
items that ...
previous year today's date is 2/2/2012, you’ll see items for
the year 2011.

Contain a date within the next Year([SalesDate]) = Year(Date()) + 1 Returns items with next year's date. If
year today's date is 2/2/2012, you’ll see items for
the year 2013.

Contain a date between Jan 1 Year([SalesDate]) = Year(Date()) and Returns items with dates between Jan 1 of
and today (year-to-date items) Month([SalesDate]) <= Month(Date()) and the current year and today. If today's date is
Day([SalesDate]) <= Day (Date()) 2/2/2012, you’ll see items for the period Jan
1, 2012 to 2/2/2012.

Contain a date that occurred in < Date() Returns items with dates before today.
the past

Contain a date that occurs in > Date() Returns items with dates after today.
the future

Examples that work with a date or range of dates other than the current date

To include items that ... Use this criteria Query result

Exactly match a date, such as #2/2/2012# Returns only items with a date of Feb 2, 2012.
2/2/2012
To include items that ... Use this criteria Query result

Do not match a date, such as Not #2/2/2012# Returns items with a date other than Feb 2, 2012.
2/2/2012

Contain values before a < #2/2/2012# Returns items with a date before Feb 2, 2012.
certain date, such as
To view items with a date on or before Feb 2, 2012, use
2/2/2012
the <= operator instead of the < operator.

Contain values after a certain > #2/2/2012# Returns items with a date after Feb 2, 2012.
date, such as 2/2/2012
To view items with a date on or after Feb 2, 2012, use
the >= operator instead of the > operator.

Contain values within a date >#2/2/2012# and Returns items with a date between Feb 2, 2012 and Feb 4, 2012.
range (between two dates) <#2/4/2012#
Note:  You can also use the Between operator to filter for a range
of values, including the end points. For example, Between
#2/2/2012# and #2/4/2012# is the same as >=#2/2/2012# and
<=#2/4/2012#.

Contain dates outside a <#2/2/2012# or Returns items with a date before Feb 2, 2012 or after Feb 4, 2012.
range >#2/4/2012#

Contain one of two dates, #2/2/2012# or Returns items with a date of either Feb 2, 2012 or Feb 3, 2012.
such as 2/2/2012 or #2/3/2012#
2/3/2012

Contain one or more of many In (#2/1/2012#, Returns items with a date of Feb 1, 2012, March 1, 2012, or April 1,
dates #3/1/2012#, 2012.
To include items that ... Use this criteria Query result

#4/1/2012#)

Contain a date within a DatePart("m", Returns items with a date in December of any year.
specific month (regardless of [SalesDate]) = 12
year), such as December

Contain a date within a DatePart("q", Returns items with a date in the first quarter of any year.
specific quarter (regardless [SalesDate]) = 1
of year), such as the first
quarter

Filter for null (or missing) Is Null Returns items where the date has not been entered.
values

Filter for non-null values Is Not Null Returns items where the date has been entered.

You might also like