Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fetch the data of specific month from SQLite database

I saved my data In SQLite Database. I saved my date in database as DATETIME datatype.

I want to retrive only the data of specific month from my SQLite databse.

I try the below query to retrive data, but it was not useful. It gives me data but it was not the specific month.

SELECT coulumn_name FROM table_name WHERE column_name Between "MM-DD-YYYY" AND "MM-DD-YYYY"
like image 564
Mohit Kanada Avatar asked May 28 '11 05:05

Mohit Kanada


1 Answers

This is probably not optimal, but you could use:

select column_name from table_name where strftime('%Y-%m', column_name) = '2011-05';
like image 159
Mat Avatar answered Oct 26 '22 09:10

Mat