> Hi Champs, I hope this is not a newbie question.:) Its not as bad as last time, but you may still get yelled at, especially since you're posting on a monday
Leave.sum("DAY(end_date) - DAY(start_date) + 1", :group => "MONTH(start_date)", :conditions => ["YEAR(start_date)=?",the_year_you_want]) This query will work, but requires that you handle leaves that begins in one month and ends in another by creating one record for each month. This could create new problems because that means you can no longer sum the number of leaves in a given period by simply counting the number of records. -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.