即将到来的7天即将到来的生日

时间:2012-07-08 15:14:35

标签: php sql

  

可能重复:
  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 - 日期

1 个答案:

答案 0 :(得分:0)

取决于您DOB所持有的格式。如果你像yyyy-mm-dd那样使用字符串比较,那么使用类似的句子:

SELECT * FROM table_name WHERE DOB <= 'computed_date'

其中computed_date使用字符串连接构建,如:

$computed_date = sprintf('%4d-%2d-%2d', $year, $day, $month);
相关问题