Pick up records that are 3 days old to win

0

I have a table named cotas that has a column ultimo_recebimento , in that column is the date in the form of time of the day that will be the last receipt of the user. I need to get all the records that are 3 days away. For example, if I have a record that the last receipt is on 12/30/2015 then if today is on 12/27/2015 it lists. I need to do this in PHP.

    
asked by anonymous 29.12.2015 / 05:38

2 answers

0

Resolved

I used the following MySQL command:

$hoje_tres = date('Y-m-d', strtotime('2015-12-28')+(60*60*24*3));

$query = $this->db->query("SELECT * FROM cotas WHERE FROM_UNIXTIME(ultimo_recebimento, '%Y-%m-%d') = '$hoje_tres'");
    
29.12.2015 / 06:08
0

In Mysql the query to be used is

$sql = "select * from cotas where datediff(ultimo_recebimento,now()) <= 3";

MySql's now () function returns the time the query was run.

*** Use the database more, operations like this are easily executed by the database and is faster.

    
30.12.2015 / 12:41