date - Using between mysql function ignoring year -
ok, have following users table:
id | name | birthday 1 | nam1 | 1980-06-29 2 | nam2 | 1997-07-08 3 | nam3 | 1997-07-20
assuming today 2012-06-29
how can users celebrate birthdays in next 15 days? have tried this:
select * users birthday between '%-06-29' , '%-07-14';
but looks not valid query.
i think safest way compare age in 15 days age today:
select * users timestampdiff(year, birthday, current_date + interval 15 day) > timestampdiff(year, birthday, current_date)
see on sqlfiddle.
Comments
Post a Comment