codec
codec

Reputation: 47

how to add minutes to datetime field then select all that matches in mysql?

I have a datetime field called "active_date" . I would like to add 10 minutes to the active_date and select those currenttime > active date + 10 mins.

I have tried the following statements but it's not working.

$sql = "SELECT * FROM records WHERE reposted = 1 AND DATEADD(minute, 10, active_date);";

$sql = "SELECT * FROM records WHERE reposted = 0 AND currentdate > DATEADD(minute, 10, active_date);";

error:

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result

Upvotes: 1

Views: 347

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270361

The syntax in MySQL uses interval, not dateadd() (at least with your syntax). Your question doesn't make that much sense, unless I interpret "actual active date" as the current date time:

SELECT *
FROM records
WHERE reposted = 1 AND now() > active_date + interval 10 minute;

Upvotes: 1

Related Questions