I have a set of records which store weekly events by using a datetime... start_at
from the first week they began.
It's not the REAL DATE, it's storing the DAY (DOW) and TIME, but is not the date I'm actually looking for.
I'm trying to figure out how I can convert/abstract the start_at
date in a way so using that I can find all of the next events that fall within the next 24 hours.
START_AT -> 2010-09-12 16:00:00 -> CONVERT into 2013-09-08 16:00:00
but I'm not sure how to abstract the start_at
for the upcoming day of the week.
I figured out how to order them but I'm not sure how to do what I want:
SELECT * FROM events ORDER BY (EXTRACT(dow FROM start_at)::int + 7 - EXTRACT(dow FROM now())::int) % 7,start_at::time
Any help would be greatly appreciated!