Say I am returning some collection of DateTime items and I only want
to compare the month. Is there a way to do this directly in the find?
Something like this...
@coll = Collection.find(:all, :conditions => ["date.month
Well, if it's mysql you could do this:
:conditions => ["MONTH(date.month) = MONTH(?)", Time.now.last_month]
Note this will pull up *every* date with february as the month regardless of the year, not just feb 08.
May lose some database independence, but it will work. Just looks up the method for your particular database.
You could also change it to look for a date BETWEEN this AND that which all Db's support.