Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

105
Vistas
postgresql query in comparing dates with duration stored in other column

I have a table like

------------------------------
id | created_date | duration 
------------------------------

duration is no.of days, now I want to select records that are created_date(timestamp)+duration(integer) > current time

I tried this in my where clause

 "select * from table where (created_date + duration days) > now()"

now resultset is empty, I have records that should come out for my requirement, I suspect my query is not right, help me get it right.

9 months ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Very close. I would do this as:

select *
from table
where created_date > now() - duration * interval '1 day'
9 months ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos