Rails where date is monday

Viewed 79

In Rails 6, how can I write a where query who find all records with a date attributes that is a monday ?

Something like : Appointment.where(date: monday?)

or Appointment.where('date.wday': 1)

1 Answers

This is working with Postgres :

Appointment.where("extract(dow from date) = ?", Date.current.monday.wday)

Related