Search code examples
sqloracleoracle11gsos

Date Difference Query


My database has a table in which it has two date columns (Start Date and End Date)

How can I list all the dates where the difference of Start Date and End Date is no more than 15 days?

This is what i tried so far:

SELECT homeworkID, subject, startdate, dateadd(day,15,startdate) as enddate
FROM homework;

Solution

  • Just add the filter predicate as per your rule/logic :

    Select start_date, 
           end_date, 
           other_columns
      From table
     Where end_date - start_date <= 15