I have a database with user birthdays… however, the year is not included. so the birthday of a random user would be say 0000-02-03 (feb 3rd). the column would be of datatype “date”
I want to find that user with a select statement, from today… as in if today was 2012-02-03 I’d want to do something like
select * from users where dob = DATE()
is this possible without a year? please inform! thanks
This is not as easy as it sounds, as there are leap years, and users having their birthday on 29th February will be returned only in 4 years. It’s better return them on 1st March if the 29th February doesn’t exists in that year. Actually, if you need to be serious about this, you have to take into account, that every 100 years, there’s no leap year, but every 400 there is.
Here is an answer that property takes into account leap-years and will always give you the users whose birthday is on the 29th of February at the same time as those on the 1st of March.