SQL that list all birthdays within the next and previous 14 days

前端 未结 7 1492
梦谈多话
梦谈多话 2021-01-05 22:30

I have a MySQL member table, with a DOB field which stores all members\' dates of birth in DATE format (Notice: it has the \"Year\" pa

7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-05 23:14

    Easy,

    We can obtain the nearer birthday (ie the birthday of this year) by this code:

    dateadd(year,datediff(year,dob,getdate()),DOB)
    

    use this in your compares ! it will work.

提交回复
热议问题