Hi,
I'm trying to select items created within a certain date range, but seem to keep getting a small syntax error - extra single quotes - whenever I try to use the built in range helper.
This works fine.
@temp_top_ten = Video.find_by_sql(["select * from votes WHERE created_at BETWEEN ? AND ?", (1.month.ago).to_s(:db), (Time.now).to_s(:db)])
But when I combine them to use the helper link this:
@temp_top_ten = Video.find_by_sql(["select * from votes WHERE created_at ?", (1.month.ago..Time.now).to_s(:db)])
I get this error MYSQL error becuase my querry is formatted by rails with extra quotes and escaped quotes: select * from votes WHERE created_at 'BETWEEN \'2007-12-03 17:17:07\' AND \'2008-01-02 17:17:07\''
Is there some trick to correct this formating? Thanks so much for the help!