search for: orginial_year

Displaying 1 result from an estimated 1 matches for "orginial_year".

2006 Apr 11
2
Getting distinct years from a date column the Rails way
I have an original_at column in my photos table. I''d like to get a list of distinct years that occur in this column, and some of the values are NULL. I see two ways of doing this. The SQLish way: photos = Photo.find :all, :select => ''distinct year(original_at)'' This is efficient in that it utilizes the database to do the filtering, and the code is not too ugly.