Works: Use MONTH Function When Querying for Months in Database (125316)



The information in this article applies to:

  • Microsoft Works for Windows 95, version 4.0
  • Microsoft Works for Windows 95, version 4.0 4.5
  • Microsoft Works for Windows 95, version 4.0 4.5a
  • Microsoft Works 2.0
  • Microsoft Works 2.0a
  • Microsoft Works 3.0
  • 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



  1. From the Tools menu, choose Filters.
  2. Select New Filter, type a name for this filter, and choose OK.
  3. Select Filter Using Formula.
  4. Enter the formula:

    =MONTH(Date)=5

    Where "Date" is the name of the field containing the date.
  5. 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

  1. From the Tools menu, choose Create New Query.
  2. Select Query View.
  3. Press the Delete key to delete any query formula already there.
  4. In the Date field, enter the formula:

    =MONTH()=5

  5. From the View menu, choose List 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()>=1#AND#MONTH()<=6

For dates in July or October:

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

Using Works for Windows 2.0

  1. From the View menu, choose Query.
  2. In the Date field, enter the formula:

    =MONTH()=5

  3. From the View menu, choose List 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()>=1 & MONTH()<=6

For dates in July or October:

=MONTH()=7 | MONTH()=10

REFERENCES

"Microsoft Works for Windows User's Guide" (version 3.0), page 547, Appendix A: "Spreadsheet and Database Functions."

"Microsoft Works for Windows User's Guide" (version 3.0), page 369 for information about using AND and OR operators.

"Microsoft Works for Windows User's Guide" (version 2.0), page 278 for information about using AND and OR operators.

Modification Type:MajorLast Reviewed:11/15/2004
Keywords:kbinfo KB125316