I have a users table with a dob (date of birth) field, in a postgres database.
I want to write a query that will retrieve the next five upcoming birthdays. I think the following needs to be considered -
- Sorting by date of birth won't work because the years can be different.
- You want the result to be sorted by date/month, but starting from today. So, for example, yesterday's date would be the last row.
- Ideally, I would like to do this without functions. Not a deal breaker though.
Similar questions have been asked on SO, but most don't even have an accepted answer. Thank you.