SELECT row by DATEPART() SELECT row by DATEPART() sql sql

SELECT row by DATEPART()


    SELECT * FROM my_table WHERE MONTH(date_column)=11


If you have an index on date_column and you concern about performance it is better to NOT apply functions over the column. (Be aware that this solution, do not anwsers exactly what you asked, becouse it also involves the year)

-- For mysql specific:SELECT * FROM my_tableWHERE date_column >= '2012-11-01'   and date_column < '2012-11-01' + INTERVAL 1 MONTH

(mysql fiddle)

-- For tsql specific:SELECT * FROM my_tableWHERE date_column >= '2012-11-01'  and date_column < DATEADD(month,1,'2012-11-01')

(tsql fiddle)