I have a Rails named_scope which is using a condition to pull specific days of the week from the table like so:
:conditions => [ 'EXTRACT(DOW FROM bookdate) IN (?)', (1..6).to_a ]
The 1..6 date range will be a variable depending on the dates the user wants,
Which produces this SQL
(EXTRACT(DOW FROM bookdate) IN (1,2,3,4,5,6)
My problem is that the days of the week are not a simple range... ie 1..6 works fine (Mon...Sat), but say 6..2 will not work correctly (Sat-Tues)... either as a ruby range or as it would need to be 6,7,1,2 and not 6,5,4,3,2 (assuming 6..2 worked in ruby, which it doesn't).
How can I create a custom range for days of the week that would accommodate a date range like this?
Any ideas?
Thanks,