使用MySQL确定今天是否是用户的生日 [英] Use MySQL to determine whether today is a user's birthday
本文介绍了使用MySQL确定今天是否是用户的生日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将所有用户的生日都存储为UNIXtimestamp,并且希望每天向当天发送生日的用户发送电子邮件.
I have all users' birthdays stored as a UNIXtimestamp and am wanting to send out e-mails each day to users that have a birthday that day.
我需要进行一个MySQL查询,该查询将获取包含当日生日的所有行.
I need to make a MySQL query that will get all of the rows that contain a birthday on today's date.
这看起来应该很简单,但是也许我只是把它复杂化了.
It seems like this should be fairly simple, but maybe I am just overcomplicating it.
推荐答案
这应该有效:
SELECT *
FROM USERS
WHERE
DATE_FORMAT(FROM_UNIXTIME(birthDate),'%m-%d') = DATE_FORMAT(NOW(),'%m-%d')
这篇关于使用MySQL确定今天是否是用户的生日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文