Rails `where` for time less than queries

前端 未结 4 1915
礼貌的吻别
礼貌的吻别 2020-12-28 18:13

Setup

Rails\' where method can take a range in a hash to generate a query that will search for a value that is within the range. For example:

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-28 18:30

    Did you try this?:

    User.where(last_deposit: Time.at(0)...10.days.ago)
    

    SQL:

    SELECT `users`.* FROM `users`  WHERE (`users`.`last_deposit` >= '1970-01-01 00:00:00' AND `users`.`last_deposit` < '2015-01-10 17:15:19')
    

提交回复
热议问题