> at = Attack.find_by_sql(\ > "SELECT MIN(occured_on) " +\ > "FROM attacks " +\ > "WHERE occured_on BETWEEN '#{start_date_str}' AND > '#{end_date_str}'")[0].min Try using Attact.connection.select_one("SELECT MIN(occured_on)...") That should return the value without needing to do [0].min. I'm actually not quite sure why it works on your machine. I would have thought you needed to do "MIN(occured_on) as min" to get the effect you're looking for. But in any case, you should grab the connection like my example above. It's a slight misuse of AR to load real objects just to get one aggregated value. -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://macromates.com/ -- TextMate: Code and markup editor (OS X) http://www.loudthinking.com/ -- Broadcasting Brain