Get shows in range
TODO: collapasable, copyable, download, etc
In postgres for a table show
with a column startTime
, how would I get all the shows that start between now and 2 hours from now?To get all the shows that start between now and 2 hours from now, you would use the NOW()
and INTERVAL
functions to create a range of time to check against the startTime
field.
Your query would look something like this:
SELECT * FROM show
WHERE startTime >= NOW() AND startTime <= NOW() + INTERVAL '2 hours';
This query will return all rows in the show
table where the startTime
is greater than or equal to the current time and less than or equal to two hours from now.
Remember to take into account the time zone setting of your PostgreSQL database and the startTime
values. If your startTime
values are stored in a specific time zone, you may need to use timezone-aware functions like NOW() AT TIME ZONE 'timezone'
to correctly compare the times.
Related Chats
Back-fill 5 months data 0.521
Avg Subs Last 24h 0.468
Rust: Replace String Substitution 0.387
Parse Date with Format 0.340
Mock `console.error` test. 0.316
Future Date: April 30th 0.308
Highlighting Graph Area 0.294
Born on March 8th 0.292
Change Git Commit Date 0.267