Yohanes AI
Yohanes AI

Reputation: 3621

Microsoft Access SQL to query a date range ignoring the year

I need to select records based on a range of month/day values, disregarding the year. I am querying an Access database, and I found a query here but it seems to select a range of years.

SELECT *
FROM   Factory
WHERE  YEAR(date) BETWEEN 1998 AND 1999 

I have tried this query, but it only shows birthdays in the current year :

SELECT * FROM user where birthday Between #09/05# and #10/10#;

In my database the birthday column contains the year to count how old they are. What query can I use to perform what I want?

Upvotes: 2

Views: 3050

Answers (2)

juergen d
juergen d

Reputation: 204766

Try

SELECT * FROM user 
WHERE (month(birthday) * 100) + day(birthday) between 0131 and 1231

Upvotes: 4

Vishwanath Dalvi
Vishwanath Dalvi

Reputation: 36621

Try this.

SELECT * 
FROM user 
WHERE birthday between #1991/12/31# and #1992/01/31#;

OR

SELECT * 
FROM user 
WHERE birthday between #12/31/1991# and #01/31/1992#;  

OR

SELECT * FROM 
user
WHERE birthday between #1991/12/31# and #1992/01/31#

Upvotes: 0

Related Questions