I’am very confused to get someone’s birthday date by changing Y-m-d to m-d in the date_birth field. How should I do? This is my current code:
$getBirthday = Karyawan::where('date_birth', Carbon::now()->format('m-d'))->get();
Thanks, I want to get someone’s birthday by taking m-d only from date_birth field. Hope u’re helping me!
2
Answers
You can query using the mysql DATE_FORMAT method and using
whereRaw
If you want to get in the day and month same, you can also use this:
See also: https://laravel.com/docs/9.x/queries#additional-where-clauses