Microsoft Access SQL查询忽略年份的日期范围

时间:2022-09-26 16:20:35

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.

我需要根据一系列月/日值选择记录,而忽略年份。我正在查询Access数据库,我在这里找到了一个查询,但它似乎选择了一系列年份。

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?

在我的数据库中,生日列包含计算它们年龄的年份。我可以使用什么查询来执行我想要的操作?

2 个解决方案

#1


3  

Try

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

#2


0  

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#

#1


3  

Try

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

#2


0  

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#