Pick up records that are there 3 days to win

Asked

Viewed 51 times

0

I have a table called 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 user’s last receipt. I need to get all the records that are 3 days from winning. For example, if I have a record that the last receipt is day 30/12/2015 then if today is day 27/12/2015 it lists. I need to do this in PHP.

2 answers

0

In Mysql the query to be used is

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

The Function now() Mysql returns the time the query was executed.

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

0


Solved

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'");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.