I have calendar and even开发者_StackOverflow社区ts. How can I find events by day? Event have created_at attribute. created_at have year, month, day. hour, minutes. How can I find only by day?
You could do something like this:
day = "04" #i.e. 4th of the month
@users = User.where("strftime('%d', created_at) = ?", day)
If you want to specify the month also then you can do this:
month = "06" # i.e. June
day = "04"
@users = User.where("strftime('%d', created_at) = ? AND strftime('%m', created_at) = ?", day, month)
Although there probably is a better way to do this.
精彩评论