On Friday 26 November 2004 11:24, David Heinemeier Hansson wrote: > > 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. > Postgresql calls the result fo the min function min by default: palga=> select min(datont) from main; min ------------ 1990-01-01 (1 row) Cheers, Han Holl