Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to parsing date column to month & day only?

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!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can query using the mysql DATE_FORMAT method and using whereRaw

$getBirthday = Karyawan::whereRaw("DATE_FORMAT(birthdate, '%m-%d') = ?", [Carbon::now()->format('m-d')])->get();
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading