How can I fetch the data of specific month from SQ

2019-02-10 08:10发布

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"

2条回答
Rolldiameter
2楼-- · 2019-02-10 08:29

This is probably not optimal, but you could use:

select column_name from table_name where strftime('%Y-%m', column_name) = '2011-05';
查看更多
兄弟一词,经得起流年.
3楼-- · 2019-02-10 08:36

Use a function retrieve only the month of the date

SELECT strftime('%m', date(column_name)) FROM table;

I believe this is the function, but I'm not so sure.

查看更多
登录 后发表回答