即将到来的生日
问题描述:
可能重复:
How would I get the birthdays of friends who are celebrating their birthday this week, this month and next month using MYSQL and PHP?即将到来的生日
我如何可以查询数据库获取在未来7天的生日与此表布局
ID - Int
名称 - VarChar
DOB - 日期
答
取决于您持有的格式DOB
。如果你持有它像yyyy-mm-dd
比你可以使用一个字符串比较,与像一个条款:
SELECT * FROM table_name WHERE DOB <= 'computed_date'
其中computed_date
是建立与字符串连接,如:
$computed_date = sprintf('%4d-%2d-%2d', $year, $day, $month);