如何抓取最近生日的人

Happy Birthday

如果想要抓取今天前後一週生日的人

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

Popular posts from this blog

CentOS7 如何新增/移除 Rich Rule for firewalld

mac 安裝 mtr

如何設定 SSL VPN 分割通道 on Fortigate 80C