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

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -