简体   繁体   中英

Notify using postgresql intervals

Say, like I have a table videoplan :

create table video_plan(
id integer,
startdate timestamp,
enddate timestamp)

So I'm having startdate: 01.02.2022, enddate: 28.02.2022

Here, I need to show a notification like 'Renew Plan' 1 week before the enddate. How to get that in PostgreSQL?

The database won't notify you. You have to query regularly with something like

SELECT ...
FROM video_plan
WHERE enddate < current_timestamp + INTERVAL '1 week';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM