我怎样才能获取特定月份的数据从SQLite数据库 [英] How can I fetch the data of specific month from SQLite database

查看:274
本文介绍了我怎样才能获取特定月份的数据从SQLite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我救了我的数据在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选择列名;
 

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';

这篇关于我怎样才能获取特定月份的数据从SQLite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆