sql >> Base de Datos >  >> RDS >> PostgreSQL

Cómo agregar el número de días en postgresql datetime

Esto le dará la fecha límite:

select id,  
       title,
       created_at + interval '1' day * claim_window as deadline
from projects

Alternativamente, la función make_interval se puede utilizar:

select id,  
       title,
       created_at + make_interval(days => claim_window) as deadline
from projects

Para obtener todos los proyectos cuya fecha límite haya terminado, use:

select *
from (
  select id, 
         created_at + interval '1' day * claim_window as deadline
  from projects
) t
where localtimestamp at time zone 'UTC' > deadline