如何抓取最近生日的人
如果想要抓取今天前後一週生日的人
SELECT * FROM customer t WHERE
MOD(DAYOFYEAR(CURDATE()) - DAYOFYEAR(t.birth) + 365, 365) <= 7
OR MOD(DAYOFYEAR(t.birth) - DAYOFYEAR(CURDATE()) + 365, 365) <= 7
如果要抓取未來兩週生日的人
SELECT * FROM customer t WHERE
MOD(DAYOFYEAR(t.birth) - DAYOFYEAR(CURDATE()) + 365, 365) <= 14
Comments