Return date as year
I wrote this little search query:
User.where("strftime('%Y', birthday) = ?", 1994)
But somehow i get no search resuts although i now that i have several users with their birthday in 1994. In the Users Table birthday is defined as date
Now i have two ideas how i could solve my problem:
1.I could check what the result of "strftime('%Y', birthday) is for a specific user or the whole user collection. But i dont know the expression! Maybe you know the expression?
2.You know what i did wrong and you have an answer?
In Rails you can write the query like:
User.where("birthday BETWEEN '?-01-01' AND '?-12-31'",1994,1994)
See this post for why this kind of format is good performance-wise when compared to something that uses "YEAR": SQL query where() date's year is $year.