Microsoft KB Archive/63840

Works: Using the YEAR, MONTH, DAY Functions to Query

PSS ID Number: Q63840 Article last modified on 10-16-1998

1.00 1.05 2.00 3.00

MS-DOS

=
========================================================= 1.00 1.05 2.00 3.00 MS-DOS kbother

= SUMMARY =

To query for records with a specific year, month, or day from a Works Database date field, for example “Date1”, use the Works functions YEAR, MONTH, or DAY as described below.

= MORE INFORMATION =

The example below represents a Works database document (in list view) with fields named Date1 and Extract. The purpose of the Extract field is to derive the year, month, or day number from the Date1 field. This example, which lists dates across a span of 10 years, demonstrates how to extract all records with a September date.

Note: The formula in the Extract field is “=MONTH(DATE1)”.

Date Extract —- ——-

Sep 14, 1990 9 Jun 12, 1988 6 Apr 14, 1989 4 Aug 1, 1987 8 Sep 15, 1986 9 Sep 7, 1985 9 Feb 4, 1984 2 Aug 4, 1983 8 Sep 1, 1982 9 Sep 4, 1981 9

Note: In Works version 3.0, if the date field has the same name as a Works function, such as Date or Year, the field name in the function must be enclosed in single quotation marks, for example, =DAY(‘Date’). This is not necessary in earlier versions.

The following is the list that results from a Query for “9” in the Extract field. Note that the month of September is extracted, regardless of the year.

Date Extract —- ——-

Sep 14, 1990 9 Sep 15, 1986 9 Sep 7, 1985 9 Sep 1, 1982 9 Sep 4, 1981 9

The formula to derive the year number in the Extract field is as follows:

=YEAR(DATE1)

The formula to derive the day number in the Extract field is as follows:

=DAY(DATE1)

KBCategory: kbother KBSubcategory: dworkskb

= Additional reference words: 1.00 1.05 2.00 3.00 sort =

Version : 1.00 1.05 2.00 3.00 Platform : MS-DOS ============================================================================= Copyright Microsoft Corporation 1998.