I have a table called konkurrencer
with column slutter
, which datatype is datetime
.
How can I select all from that table where the rows "ends in" 1 hour?
Let's say I have a prize into that table. It ends in 1 hour, therefore it has to output the row. If the row ends in 2 hours it should not output it. Only if 1 hour.
But how?
use this query.
SELECT * FROM konkurrencer WHERE slutter < DATE_ADD(NOW(), INTERVAL 1 HOUR) AND slutter >= NOW()
Try like this
<?php
$time = time() - (60*60); //Gives you last hour
$sql = "SELECT *
FROM konkurrencer
WHERE slutter = $time";
?>