ACC: Dynamic Query to Return Records for the Previous MonthLast reviewed: November 12, 1997Article ID: Q176645 |
The information in this article applies to:
SUMMARYModerate: Requires basic macro, coding, and interoperability skills. This article demonstrates how to create a query that returns all the records in which the value of a date field falls within the previous month.
MORE INFORMATIONTo create a query that returns the data from the previous month based on the current date, use the Between...And operator with the DateSerial() function in the Criteria of the date field. The DateSerial() function returns a date for a specified year, month, and day. The syntax of the DateSerial() function is:
DateSerial(year, month, day)The following example returns all records from the Orders table of the sample database Northwind.mdb (or NWIND.MDB in version 2.0) in which the value in the ShippedDate field (or Shipped Date field in version 2.0) falls within the previous month. CAUTION: Following the steps in this example will modify the sample database Northwind.mdb (or NWIND.MDB in version 2.0). You may want to back up the Northwind.mdb (or NWIND.MDB) file and perform these steps on a copy of the database.
DateSerial(97,1,0)returns
12/31/96 REFERENCESFor more information about the Between...And operator, search the Help Index for "Between...And operator." For more information about the DateSerial() function, search the Help Index for "DateSerial." For more information about other expressions to manipulate dates, see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q88657 TITLE : ACC: Functions for Calculating and Displaying Date/Time Values |
Additional query words: prior
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |