Reputation: 4242
I am trying to add a certain number of minutes to the current time in an SQL table. For this purpose, I tried the DATEADD SQL function:
$insert = 'INSERT INTO Waiting_list(
ID_Patient,
Arrival_Time,
Classification,
Target_Time)
VALUES (
"'.$_SESSION['id'].'",
NOW(),
"'.$_SESSION['classification'].'",
DATEADD(MINUTE, @'.$waitingtime.', @NOW()))';
The column Target_Time has the type DATETIME
.
Although, I am getting an SQL error near '())'. Doesn't NOW()
work with DATEADD
?
Upvotes: 1
Views: 92
Reputation: 3846
It kinda looks like you may be using SQL-SERVER? in that case, try this:
$insert = 'INSERT INTO Waiting_list(
ID_Patient,
Arrival_Time,
Classification,
Target_Time)
VALUES (
"'.$_SESSION['id'].'",
getdate(),
"'.$_SESSION['classification'].'",
DATEADD(MINUTE, @'.$waitingtime.', getdate()))';
Upvotes: 0
Reputation: 21677
In MYSQL you should use date_add:
date_add(now(), interval waitingtime MINUTE)
Upvotes: 1