gpt4 book ai didi

sql - 从 MS Access 表中过滤最近 3 天的生日记录

转载 作者:行者123 更新时间:2023-12-02 09:04:51 25 4
gpt4 key购买 nike

我正在尝试根据 MS Access 中 tb_Employee 表中的 birthday_date 列过滤生日在过去 3 天内(包括今天)的员工记录。我知道我可以根据日期获取最近 3 天的记录:

Select * from tb_Employee where ([Date_Column] >= NOW()-3

但就我而言,birthday_date 列中的日期是去年的日期(例如 1975 年 1 月 18 日)。请帮我解决这个问题

示例: enter image description here

最佳答案

我可能建议:

select * from tb_employee 
where
(dateserial(year(date()),month(birthday_date),day(birthday_date)) between date()-3 and date()) or
(dateserial(year(date())-1,month(birthday_date),day(birthday_date)) between date()-3 and date())

用文字来说,这个查询是这样说的:

“选择今年生日在过去 3 天到今天之间的员工,或者去年生日在过去 3 天到今天之间的员工”

关于sql - 从 MS Access 表中过滤最近 3 天的生日记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59812027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com