Mealplan: Allow ordering until 9am Imagine you have a meal service and everyday there is a different meal which customers can order.
Mon, Dec 12: Pasta
Tue, Dec 13: Pizza
Wed, Dec 14: Gnocci

Orders are possible until 9am.
This mean Monday on 8am customers may order Pasta for today, at 9:15am they are no longer allowed to order for today.
How to handle this is with PostgreSQL.
I see two ways:

Create a cron job which switches the column &quot;orderable&quot; to False.
Create a view which calculates the field &quot;orderable&quot; on the fly.

Is there a feasible third or forth way?
Which way is simple and robust?
As long as you have the dates in a date column, you can use a simple CASE to choose, which meal is selected.
The result if the query, depends when you look for the example, it will choose pasta before 9 in the morning a Minute later and you would get  gnocchi, you only have to enter the menus ahead of time
In an event you could delete the old menus, but that is not necessary, as you will not have millions of rows.


CREATe TABLe &quot;OrDERS&quot; (&quot;orderdate&quot; date, &quot;food&quot; varchar(40))




INSERT INTO &quot;OrDERS&quot; VALUES (CURRENT_DATE  ,'Pasta'), (CURRENT_DATE  + INTERVAL '1 day','Gnocchi')




SELECT to_char(&quot;orderdate&quot;,'Dy, Mon DD'), &quot;food&quot; FROM &quot;OrDERS&quot; 
WHERE &quot;orderdate&quot; = 
       CASE WHEN NOW() &lt; now()::date + interval '9h' THEN now()::date
            ELSE now()::date + INTERVAL '1 day'
       END


to_char     | food  
:---------- | :-----
Tue, Dec 22 | Gnocci


db&lt;&gt;fiddle here