sammaell
asked on
Selecting specific dates - T- SQL
i need a query that will let me select distinct months, from a column that contains the date in the format: 10/20/2006 12:00:00 AM
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
However, it's better to use a date range expression that SQL can use to search an index (if one exists now or in the future):
SELECT ...
FROM ...
WHERE date >= '20061001' AND date < '20061101' --to get Oct 2006 only
SELECT ...
FROM ...
WHERE date >= '20061001' AND date < '20061101' --to get Oct 2006 only
from BOL
MONTH
Returns an integer that represents the month part of a specified date.
Syntax
MONTH ( date )