sql search with higher and lower end date

0

My code should return values from the database, related to the current day (today), but only related to the month and day, I searched a lot but could not find something that would help me

$data_atual = date("d-m");
$mostraDados = mysqli_query($conecta,  "SELECT * FROM sql WHERE ativo = 's' AND inicio >= '".$data_atual."'")or die (mysqli_error());

In the column inicio of the table is the date, such as 13-10 , then the query line should return everything above the 13th day of month 10, but this is giving error. In this case, the variable $data_atual takes the day and month of the server to make the query and check with the start column.

    
asked by anonymous 13.10.2017 / 07:42

1 answer

2

You will have to use DATE() function to convert the two dates to the "yyyy-mm-dd" format and compare them. So to get all records for today's date, you would have the following query:

SELECT * FROM sql WHERE ativo = 's' AND DATE(inicio) >= DATE(NOW())
    
13.10.2017 / 20:45