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