Reputation: 107
I'd like to know if its possible and/or sensible to use DATE_ADD with a prepared statement in PHP. I have a number of variables I'm passing to PHP that I want to insert, one is a SQL format datetime and the other is the same datetime but I want to add a number of days to it. The number of days is also held in a variable passed to PHP.. Here's my query so far
$mySql="INSERT INTO delay (delayBookID, delayEED0, delayEDD1, delayDDC, delayUserID, delayCreated)
VALUE (?,?,DATE_ADD(?,? DAY),?,?,NOW())";
to clarify: here my bind param
$stmt->bind_param('ssssss', $bookID, $edd0, $edd1, $xD4Book, $ddc, $userID);
Can anyone help??
Thanks in advance
Upvotes: 0
Views: 1073
Reputation: 28253
You can use DATE_ADD
in an INSERT statement, however, you are missing the key word INTERVAL in DATE_ADD
.
It should be DATE_ADD(?, INTERVAL ? DAY)
Upvotes: 2