Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

102
Views
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.

8 months ago · Santiago Trujillo
1 answers
Answer question

0

Very close. I would do this as:

select *
from table
where created_date > now() - duration * interval '1 day'
8 months ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.