I'd like to pull out records where the day of the week is Friday or Saturday. So I have the following query:
SELECT aId, aStatus
WHERE DATEPART(weekday,aDate) = 5 OR DATEPART(weekday,aDate) = 6
Open in new window
I get an error message thus:
Microsoft OLE DB Provider for SQL Server error '80040e14'
An expression of non-boolean type specified in a context where a condition is expected
Is it possible to use Datepart in this way, and if so, how can I fix this query? If not, what is the best way to achieve the same result?
Keep in mind that doing a query like that, with calculations on a database field, will always result in a table scan, so performance may be pretty poor if the table is large. Use a calendar table or an indexed computed field if you need to improve performance.