0
Select projectname
from project
where to_char(start_date, 'yyyy-mm-dd') - to_char(end_date, 'yyyy-mm-dd') <= 10;

Hi, so i want to get a project that is less than or equal to 10 days long, I am new to SQL, not sure if I am doing it right or not.

user2786596
  • 135
  • 2
  • 5
  • 10

2 Answers2

1

you just need to change the following thing in your Code

Select 
     projectname
FROM 
      project
WHERE
       DATEDIFF(DAY,start_date,end_date) <= 10;

fOR DAys between 10 to 40 just modify the code

DATEDIFF(DAY,start_date,end_date) <= 10 AND DATEDIFF(DAY,start_date,end_date) >= 40;
Hardik Parmar
  • 1,053
  • 3
  • 15
  • 39
0

This won't work e.g.

20150101 - 20141231 = 8870!

So, as others have said, perform the date arithmetic on the date objects, and then compare to a number.

davek
  • 22,499
  • 9
  • 75
  • 95