Microsoft KB Archive/125316

= Works: Use MONTH Function When Querying for Months in Database =

Article ID: 125316

Article Last Modified on 11/15/2004

-

APPLIES TO


 * Microsoft Works 4.0 Standard Edition
 * Microsoft Works 4.5 Standard Edition
 * Microsoft Works 4.5a
 * Microsoft Works 2.0 Standard Edition
 * Microsoft Works 2.0a
 * Microsoft Works 3.0 Standard Edition
 * Microsoft Works 3.0a
 * Microsoft Works 3.0b

-



This article was previously published under Q125316



SUMMARY
In the Works for Windows Database module, querying for dates that fall in a particular month can be done with the MONTH function.

NOTE: In Works 4.0, 4.5, or 4.5a, these filters must be created using the Filter Using Formula option. In Works 3.0x, these queries must be entered in the Query view of the Database.

The MONTH function will return an integer from 1 to 12 specifying the month of the given date. For instance, the following formula will bring up all records which have the month of May in the BirthDate field.

=MONTH(BirthDate)=5



MORE INFORMATION
Below are some query examples using the MONTH function to find records in the database.

NOTE: The following queries will give you all records for the specified month(s), regardless of the year. To specify a month or range of months in a specific year, either use the actual dates in the query, or add the year function to the query as in the following example, where "Date" is the name of the field containing the date:

=MONTH(Date)=5#AND#YEAR(Date)=95

Using Works 4.0, 4.5, or 4.5a
 From the Tools menu, choose Filters. Select New Filter, type a name for this filter, and choose OK. Select Filter Using Formula. Enter the formula:

=MONTH(Date)=5

Where "Date" is the name of the field containing the date. Choose Apply Filter to see the result of the query.

RESULT: All records from the month of May will be displayed.

Other Query Examples
For dates between two months (for example, between January and June):

=MONTH(Date)>=1#AND#MONTH(Date)<=6

For dates in July or October:

=MONTH(Date)=7#OR#MONTH(Date)=10

Using Works for Windows 3.0x
 From the Tools menu, choose Create New Query.</li> Select Query View.</li> Press the Delete key to delete any query formula already there.</li> In the Date field, enter the formula:

=MONTH=5

</li> From the View menu, choose List to see the result of the query.</li></ol>

RESULT: All records from the month of May will be displayed.

Other Query Examples
For dates between two months (for example, between January and June):

=MONTH>=1#AND#MONTH<=6

For dates in July or October:

=MONTH=7#OR#MONTH=10

Using Works for Windows 2.0
 From the View menu, choose Query.</li> In the Date field, enter the formula:

=MONTH=5

</li> From the View menu, choose List to see the result of the query.</li></ol>

RESULT: All records from the month of May will be displayed.

Other Query Examples
For dates between two months (for example, between January and June):

=MONTH>=1 & MONTH<=6

For dates in July or October:

=MONTH=7 | MONTH=10

<div class="references_section">