I need to make an appointment at the bank to see the birthday of the current month. Such a query, see:
SELECT * FROM membros WHERE day(dataNasc) = day(CURRENT_DATE) and month(dataNasc) = month(CURRENT_DATE);
How could I make this query in Laravel?
I tried to do this way but he is returning dates that are not today today that in this case today 03/09/2017 in> ). Because it returns date as 04/09
, 05/09
, etc.
See how I'm trying:
$date = Membro::all();
foreach ($date as $d) {
$explode = explode('-', $d->dataNasc);
}
$query = DB::table('membros')
->whereDay('dataNasc', $explode[2])
->whereMonth('dataNasc', $explode[1])
->get(['nome', 'imagem']);
dd($query);
It returns me 4 values. where only 3 values are according to the current date at the moment, but if I go to phpmyadmin
and put the command
SELECT * FROM membros WHERE day(dataNasc) = day(CURRENT_DATE) and month(dataNasc) = month(CURRENT_DATE);
Does it return only the 3 correct values of the current date and the current month? How can I resolve this?