botvector.net domain for sale $2k usd (negotiable). Em@il me t0: alex DOT creopolis at gmail DOT com

My Git activity

02 September 2007

:conditions => ["created BETWEEN...

Best way to get query by "from" date and "till date" is:


range = "created_at #{(12.months.ago..Time.today).to_s(:db)}"

Will result in creating String = "created_at BETWEEN "03-09-2006" AND "03-09-2007""
AND then

@data = MyModel.find(:all, :conditions => ["code=? AND #{range}", 2])

1 comment:

Tulio Gensana said...

Muy buen ejemplo ra visualizar registros entre un rango de fechas utilizando created_at.