Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

310
Views
How to get a new column in the case in postgresql

I have a table with startdate and enddate.

where start date is greater than endate i need to calculate the total days as 30 otherwise (enddate - startdate)+1 ... how do i create a case statement for it.

Select case when 'startdate >  enddate' then 30
when 'startdate >  enddate' then (fine_fatturazione - startdate )+1
end
as td from table1


startdate   enddate
04-10-2015  04-12-2015
10-07-2015  09-08-2015
05-12-2015  04-01-2016
07-02-2016  04-01-2016
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Select case when table1.startdate >  table1.enddate then 30
else table1.enddate - table1.startdate + 1
end
as td 
from table1
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!