使用DATE_ADD()时SQL语法错误

时间:2021-11-03 22:33:55

so I am trying to return all appointments more than 24 hours ahead of time. I'm positive the error in the code is around the DATE_ADD stuff, so I know that the PHP variables are set correctly. I think I am just thinking about DATE_ADD wrong. I have also tried several variations of brackets with no luck. Just CURDATE() works. Thanks for any help!

所以我试图提前超过24小时返回所有约会。我很肯定代码中的错误是围绕DATE_ADD的东西,所以我知道PHP变量设置正确。我想我只是在考虑DATE_ADD错误。我也试过几个方括号而没有运气。只是CURDATE()有效。谢谢你的帮助!

$sql =  "   SELECT DISTINCT timeBlocks.date
            FROM timeBlocks
            WHERE timeBlocks.location = '".$appointmentLocation."' AND timeBlocks.school = '".$_SESSION["school"]."' AND timeBlocks.date >= DATE_ADD(curdate(), INTERVAL 1 YEAR)
            ORDER BY timeBlocks.date ASC;"; 

1 个解决方案

#1


3  

Maybe this is too obvious, but it says INTERVAL 1 YEAR instead of 24 hours.

也许这太明显了,但它说INTERVAL 1年而不是24小时。

#1


3  

Maybe this is too obvious, but it says INTERVAL 1 YEAR instead of 24 hours.

也许这太明显了,但它说INTERVAL 1年而不是24小时。