我怎样才能获取特定月份的数据从SQLite数据库数据库、数据、SQLite

2023-09-04 07:27:30 作者:不舍晴天

我救了我的数据在SQLite数据库。 我救了我的日期,数据库为DATETIME数据类型。

我想从我的SQLite DATABSE retrive特定月份的只有数据。

我尝试以下查询以检索数据,但它是没有用的。它给我的数据,但它不是具体月份。

  SELECT coulumn_name FROM table_name的WHERE之间MM-DD-YYYY栏和MM-DD-YYYY
 

解决方案

这可能不是最优的,但你可以使用:

 从TABLE_NAME那里的strftime(%Y-%M,列名)=2011-05选择列名;
 
Android开发连接sqlite并通过SQLiteStudio实时读取数据库

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"

解决方案

This is probably not optimal, but you could use:

select column_name from table_name where strftime('%Y-%m', column_name) = '2011-05';