0
I am trying to make a query of users who entered my database in the last 3 days but have no return $condicaoData = date('yyyy-MM-dd HH:mm:ss'); $dataa = $condicaoData - '0000-03-00 00:00:00';
$connect = new PDO("mysql:host=localhost;dbname=xxxx", "xxxx", "xxxx"); $query = "SELECT * FROM leads WHERE data >= '$dataa' ORDER BY ID DESC";
$statement = $connect->prepare($query); $statement->execute(); $result = $statement->fetchAll();
Note: My date in the database looks like this: 2020-10-08 20:20:5 (Timestamp)
Have you tried:
DATE_SUB(CURRENT_DATE, INTERVAL 3 DAY);
?– anonimo
Hello Skatethefut10, there are other questions about date, just change the number of days by the desired number.
– Guilherme Nascimento
I haven’t tried this DATE_SUB(CURRENT_DATE, INTERVAL 3 DAY) method yet; Is Interval default? Note: I forgot to put in the thread but the format of my date is like this: 2020-10-08 20:20:5
– Marco Antonio Sktf10
Please refer to the manual https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html to determine which function best suits your needs.
– anonimo