Jake
Jake

Reputation: 3486

Selecting Month and year from SQL

If in a column I have a timestamp ie. 2010-04-01 10:40:20 How can I use SQL to select everything from October 2011?

Upvotes: 3

Views: 153

Answers (2)

Mark Byers
Mark Byers

Reputation: 837886

SELECT *
FROM yourtable
WHERE col1 >= '2011-10-01' AND col1 < '2011-11-01'

Upvotes: 6

JellyBelly
JellyBelly

Reputation: 2431

try this:

SELECT * FROM table WHERE MONTHNAME(filed_date) = 'October' AND YEAR(field_date)='2011'

Upvotes: 2

Related Questions