sql server 2000
For 1 and 3, use date ranges wherever possible so as to avoid complex
expressions and type conversions and to help maximize the benefit of any
indexes. Examples:
One day:
SELECT *
FROM YourTable
WHERE date_col >= '20050717'
AND date_col < '20050718'
One month:
SELECT *
FROM YourTable
WHERE date_col >= '20050701'
AND date_col < '20050801'
For 2 and 4, take a look at the DATEPART function in Books Online.
--
David Portas
SQL Server MVP
--
|