Find records between time of the day (not date only time)

It’s quite straightforward to find records between two datetime. But it would be little tricky to find records between two time, only time not datetime. We can write it that way:

Task.where([":date_time >= start_time::time AND :date_time <= end_time::time", { date_time: DateTime.current.strftime('%H:%M:%S') }])

Find records of specific weekday

Say, you want to find record only which are created on Monday, so write query like this:

Task.where([":wday = ANY (days_of_the_week)", { wday: Date.current.strftime('%A') }])