Rails ActiveRecord - how to fetch records between two dates

后端 未结 8 1241
执念已碎
执念已碎 2020-12-29 23:16

I have in the database two date columns - from_date and to_date.

Example:

  • from_date: 2012-09-10
8条回答
  •  感情败类
    2020-12-29 23:47

    data = ModelName.find(:all, :conditions => "today >= from_date and today <= to_date")
    

提交回复
热议问题