-1

i have table which has column completed_at type (datetime)

i am inserting date in it by php date('Y-m-d H:i:s') 2016-05-17 00:00:14

I want to select data which has 3 hours ago

<?php
$sql = "Select `id`,`file` from `uploader` where `completed_at` < CURDATE() - INTERVAL 3 HOUR";
        $DB = new DB();

        mysqli_query($DB->db_connect(), $sql);

?>

but it gives me wrong answer.

Sufyan
  • 506
  • 2
  • 6
  • 18
  • Possible duplicate of [Get records from last hour](http://stackoverflow.com/questions/19743850/get-records-from-last-hour) – Ardit Meti May 17 '16 at 11:15

1 Answers1

2

Try this:

SELECT FROM table_name
 WHERE completed_at  < NOW() - INTERVAL 3 HOUR
Jayesh Chitroda
  • 4,987
  • 13
  • 18
  • thank you for answer Jayesh i echo date('Y-m-d H:i:s') // 2016-05-17 06:47:30 but it gives me also this record 2016-05-17 06:41:29 which has not yet 3 hours – Sufyan May 17 '16 at 11:50