1周前的生日提醒。 如何查看生日日期的当前日期? 我的数据库是MySQL
<?php
$birthday_query = $link->query("SELECT u.u_username, u.u_birthday
FROM ".TBL_PREFIX."users u
WHERE u.u_banned = '0'
AND u_confirmed = '1'
AND u_birthday LIKE '" . $link->asf_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%'
ORDER BY u_username ASC");
?>
它不起作用。
答案 0 :(得分:1)
使用mysql NOW
&amp; + INTERVAL 7 DAY
要获得从现在开始的1周后的日期,请使用DATE_FORMAT
指定您的u_birthday格式
试试这个......
$birthday_query = $link->query("SELECT u.u_username, u.u_birthday
FROM ".TBL_PREFIX."users u
WHERE u.u_banned = '0'
AND u_confirmed = '1'
AND u_birthday = DATE_FORMAT(NOW(), '%Y-%m-%d') + INTERVAL 7 DAY
ORDER BY u_username ASC");
答案 1 :(得分:1)
试试这个:
"SELECT *
FROM your_tbl
WHERE (DATE_ADD(YOUR_DATE, INTERVAL -7 DAY)) = " DATE(); //Your php current date