Hi all We have a table that has a datetime field (created_at) that we have to summarize based on it. For instance, we have to count all posts grouped by created_at field. Our first approach is: self.count(:all, :conditions => some_condition, :group => :created_at) This lead to an array that have the following structure: [ [ created_at field ] , [number of posts in that date], [ another date ] , [...], ] But, as the created_at field is datetime, the group doesn''t group anything as this field saves the date and time with microseconds. What we need is to group by date only. Our next approach was: self.count(:all, :conditions => some_condition, :group => "DATE(''CREATED_AT'')") This works on SQL but in Rails, it returns an array like this: [ [nil, total number of posts] ] I think that Rails tries to find the group field and as the field is between the DATE function, it doesn''t find it and returns nil. Does anyone have a solution? Best regards Marcos -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---