Friday, February 24, 2012

date criteria

Im looking for a SELECT statement to pull all records from a table where the difference between two dates (columns in the table) are greater than a certain number (5 in this case.)

So lets say theres a table called Projects, and in this table is ProjectStart and ProjectComplete. I would need all the records where the ProjectComplete is more than 5 days past ProjectStart.

(So for example a ProjectStart of 9/8/03 and a ProjectEnd of 9/10/03 wouldnt show up, but a ProjectStart of 8/5/03 and a ProjectEnd of 9/22/03 would.)

Thanks!SELECT * FROM Projects
WHERE DateDiff(dd, ProjectStart, ProjectComplete) > 5

No comments:

Post a Comment