<tfoot id='NA7hJ'></tfoot>
  1. <i id='NA7hJ'><tr id='NA7hJ'><dt id='NA7hJ'><q id='NA7hJ'><span id='NA7hJ'><b id='NA7hJ'><form id='NA7hJ'><ins id='NA7hJ'></ins><ul id='NA7hJ'></ul><sub id='NA7hJ'></sub></form><legend id='NA7hJ'></legend><bdo id='NA7hJ'><pre id='NA7hJ'><center id='NA7hJ'></center></pre></bdo></b><th id='NA7hJ'></th></span></q></dt></tr></i><div id='NA7hJ'><tfoot id='NA7hJ'></tfoot><dl id='NA7hJ'><fieldset id='NA7hJ'></fieldset></dl></div>
      <bdo id='NA7hJ'></bdo><ul id='NA7hJ'></ul>
    1. <small id='NA7hJ'></small><noframes id='NA7hJ'>

    2. <legend id='NA7hJ'><style id='NA7hJ'><dir id='NA7hJ'><q id='NA7hJ'></q></dir></style></legend>
    3. SQLite 数据库 - 选择两个日期之间的数据?

      SQLite database - select the data between two dates?(SQLite 数据库 - 选择两个日期之间的数据?)

      <i id='C47MW'><tr id='C47MW'><dt id='C47MW'><q id='C47MW'><span id='C47MW'><b id='C47MW'><form id='C47MW'><ins id='C47MW'></ins><ul id='C47MW'></ul><sub id='C47MW'></sub></form><legend id='C47MW'></legend><bdo id='C47MW'><pre id='C47MW'><center id='C47MW'></center></pre></bdo></b><th id='C47MW'></th></span></q></dt></tr></i><div id='C47MW'><tfoot id='C47MW'></tfoot><dl id='C47MW'><fieldset id='C47MW'></fieldset></dl></div>
        <tbody id='C47MW'></tbody>
      <legend id='C47MW'><style id='C47MW'><dir id='C47MW'><q id='C47MW'></q></dir></style></legend>

          <small id='C47MW'></small><noframes id='C47MW'>

              <bdo id='C47MW'></bdo><ul id='C47MW'></ul>

                <tfoot id='C47MW'></tfoot>
                本文介绍了SQLite 数据库 - 选择两个日期之间的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想按日期选择我的数据 - 从一个日期到另一个日期,所以我有这个查询,

                I want to select my data by date - from a date until another date, so I have this query,

                SELECT * FROM mytalbe WHERE date BETWEEN '2014-10-09' AND '2014-10-10'
                

                但是这个查询只返回'2014-10-09'中的数据,不包括'2014-10-10'中的数据,除非我把查询改成下面这个,

                But this query only return the data in '2014-10-09', excluding the data in '2014-10-10', unless I change the query to this below,

                SELECT * FROM mytalbe WHERE date BETWEEN '2014-10-09' AND '2014-10-11'
                

                这不是理想的解决方案.如何选择包含2014-10-10"中的数据?

                This is not an ideal solution. How can I select the data including the data in '2014-10-10'?

                注意:

                我认为我的问题与其他重复问题不同,

                I think my problem is different from other duplicate questions becos,

                1. 我的日期类型是文本
                2. 我需要选择不含时间的日期数据.
                3. 它是一个 sqlite 数据库...

                我的数据样本...

                    sid     nid timestamp   date    
                1   20748   5   1412881193  2014-10-09 14:59:53 
                2   20749   5   1412881300  2014-10-09 15:01:40 
                3   20750   5   1412881360  2014-10-09 15:02:40
                

                推荐答案

                你也可以不使用 between.

                select * from mytable where `date` >= '2014-10-09' and `date` <= '2014-10-10'
                

                示例:

                mysql> create table dd (id integer primary key auto_increment, date text);
                Query OK, 0 rows affected (0.11 sec)
                
                mysql> insert into dd(date) values ('2014-10-08'), ('2014-10-09'), ('2014-10-10'), ('2014-10-11');
                Query OK, 4 rows affected (0.05 sec)
                Records: 4  Duplicates: 0  Warnings: 0
                
                mysql> select * from dd where date >= "2014-10-09" and date <= "2014-10-10";
                +----+------------+
                | id | date       |
                +----+------------+
                |  2 | 2014-10-09 |
                |  3 | 2014-10-10 |
                +----+------------+
                2 rows in set (0.01 sec)
                

                因为它包括时间,而你不想要时间.这个:

                Since it includes time, and you dont want the time. this:

                select substring(date, 1, 10) from dd where substring(date, 1, 10) between '2014-10-09' and '2014-10-10';
                

                问题再次更新,补充答案

                呃.你有时间戳字段吗?在这种情况下:

                Ugh. you have timestamp fields? in that case this:

                select date(from_unixtime(timestamp)) from mytabel where date(from_unixtime(timestamp)) between '2014-10-09' and '2014-10-10'
                

                终于到了sqlite

                select date(datetime(timestamp, 'unixepoch')) 
                  from mytable 
                    where date(datetime(timestamp, 'unixepoch')) 
                      between '2014-10-09' and '2014-10-10';
                

                这篇关于SQLite 数据库 - 选择两个日期之间的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                SQL query to group by day(按天分组的 SQL 查询)
                What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
              1. <tfoot id='zbfQi'></tfoot>

              2. <small id='zbfQi'></small><noframes id='zbfQi'>

                  <tbody id='zbfQi'></tbody>

                    <i id='zbfQi'><tr id='zbfQi'><dt id='zbfQi'><q id='zbfQi'><span id='zbfQi'><b id='zbfQi'><form id='zbfQi'><ins id='zbfQi'></ins><ul id='zbfQi'></ul><sub id='zbfQi'></sub></form><legend id='zbfQi'></legend><bdo id='zbfQi'><pre id='zbfQi'><center id='zbfQi'></center></pre></bdo></b><th id='zbfQi'></th></span></q></dt></tr></i><div id='zbfQi'><tfoot id='zbfQi'></tfoot><dl id='zbfQi'><fieldset id='zbfQi'></fieldset></dl></div>

                    <legend id='zbfQi'><style id='zbfQi'><dir id='zbfQi'><q id='zbfQi'></q></dir></style></legend>
                      <bdo id='zbfQi'></bdo><ul id='zbfQi'></ul>