Return dates based on day and month only

Lisad

Access Beginner
Local time
Today, 08:20
Joined
Jan 26, 2005
Messages
31
I would like a query to return dates based upon the input of just the day and month. At the moment I have a parameter query which asks for 'start date' and 'end date' and this works fine, but I want the query to return all the records for all the years in the database and not just the current one (date format is dd/mm/yy)

So if I type <start date> 01/01 and <end date> 02/01 the query will return:

01/01/04
01/01/05
01/01/06
02/01/04
02/01/05
02/01/06

Does anyone know a solution - I have been searching all afternoon!!??
 
Hi Lisa -

Probably the best way is to use DatePart() to extract the day of the year.

E.g. DatePart("y", DateVariable)

SELECT * FROM tblData
WHERE ((DatePart ("y", tblData.DateValue) >= DatePart("y", StartDate) )
AND (DatePart ("y", tblData.DateValue) <= DatePart("y",EndDate) ))

Not sure what will happen with leap days.

- Mike
 

Users who are viewing this thread

Back
Top Bottom