Querying Date Field, Disregarding Year

D

dimatisah

I have an Access database of client information with their birthdate stored
in a field called Birthday, in m/d/yyyy format.

I need a query that will let me find everyone with a birthdate during a
certain date range no matter what year they were born. For example, if I
wanted everyone born during this week, from 3/22-3/28 of any year.

Is there a way to either: A) Change my date fields in the table to only m/d
somehow? or B) Query the month and day only, ignoring the year?

I'd prefer Option B, but am open to anything that might make it work.
Thank you! :)
 
J

Jerry Whittle

PARAMETERS [Start Date] DateTime, [End Date] DateTime;
SELECT ClientInfo.*
FROM ClientInfo
WHERE DatePart("y",[Birthday])
Between DatePart("y",[Start Date])
And DatePart("y",[End Date]);

Make sure that the table name, ClientInfo, it correct. It will prompt you
for dates. If you leave off the year, Access assumes the current year.

One fly in the ointment: Leap Year's will be one day off after the end of
February.
 
D

Daryl S

Dimatisah -

You can add a field in your query for the birthday based on the current
year, and then add criteria:

BirthDateThisYear:
DateSerial(Year(Date()),Month([Birthdate]),Day([Birthdate]))

Between [StartDate] And [EndDate]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top