ruby on rails - How to search through array of strings using BETWEEN in Active Record POSTGRES, -
subscriptions canceled_at: ["2017-04-07t09:52:17-05:00", "2017-04-01t09:52:17-05:00"]
canceled_at array of strings. each element datetime converted string.
above subscriptions table. trying query through , find records have canceled_at date within given week.
date = date.today subscription.where("any subscriptions.canceled_at between '#{date.beginning_of_week(:sunday)}' , '#{date.end_of_week(:sunday)}'"
ruby 2.3.1p112
subscription.where(canceled_at:(date.beginning_of_week(:sunday)..date.end_of_week(:sunday)))
edit: missing closing parentheses
Comments
Post a Comment