query where date = Date.today with Rails, MySQL, and Active Record

后端 未结 3 570
抹茶落季
抹茶落季 2021-02-12 23:08

I see in the Active Record docs, you can query for a date using a greater than / less than comparison. However, what if you want to select where date = Date.today or must I quer

3条回答
  •  长发绾君心
    2021-02-13 00:06

    For me just works like this:

    @fisrt_payment_day = Invoice.where("DATE(date_first_payment) >= ?", Date.today - 1.day)
    

提交回复
热议问题