Date Difference Query

43 views Asked by At

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;
1

There are 1 answers

2
Lalit Kumar B On BEST ANSWER

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