Answer the question
In order to leave comments, you need to log in
How can Ruby on Rails group data from a model by a specific time (month)?
For example, there is a User model (it has a standard field :created_at).
So is it possible to find out the number of users in December, for example?
Answer the question
In order to leave comments, you need to log in
It is possible like this:
User.where(created_at: Date.parse('December')...Date.parse('December')+1.month).count
User.where("strftime('%m', created_at) = ?", '12').count
for sqlite
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question