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

Glib GIOChannel -

jsp - java.sql.SQLException: [Microsoft][ODBC Microsoft Access > Driver] Too few parameters. Expected 1 -

delphi - When I encode/decode SMS PDU (GSM 7 Bit) user data, do I need prepend the UDH first? -