I am attempting to query in RealmJS on a Date field for birthdays.
I want to find all the people that have a birthday today.
The problem is that I can't ignore the year. Is there a way to do this?
My code:
const today = new Date();
const morning = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0,0,0,0);
const evening = new Date(today.getFullYear(), today.getMonth(), today.getDate()+1, 0,0,0,0);
const studentBirthdaysToday = realm.objects('Student').filtered('birthday >= $0 && birthday < $1', morning, evening);
Even though there are students with a birthday today, it doesn't show because it's looking for the year 2020.
How can I ignore the year?
This is how student.birthday is formatted in the database, it's a Realm Date:
2000-08-25T10:00:00.000Z