SQL 在日期之间选择 [英] SQL Select between dates

查看:25
本文介绍了SQL 在日期之间选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 sqlite 来选择销售报告的两个范围之间的数据.要从两个日期之间选择数据,我使用以下语句:

I am running sqlite to select data between two ranges for a sales report. To select the data from between two dates I use the following statement:

SELECT * FROM test WHERE date BETWEEN "11/1/2011" AND "11/8/2011";

该语句获取所有日期,即使是那些超出标准的日期.您看到输入的日期格式与我返回的格式相同.我不确定出了什么问题,但感谢我能找到的任何帮助.谢谢!

This statement grabs all the dates even those outside the criteria. The date format you see entered is in the same format that I get back. I'm not sure what's wrong but appreciate any help I can find. Thanks!

推荐答案

SQLLite 要求日期为 YYYY-MM-DD 格式.由于您的数据库中的数据和查询中的字符串不是这种格式,因此它可能将您的日期"视为字符串.

SQLLite requires dates to be in YYYY-MM-DD format. Since the data in your database and the string in your query isn't in that format, it is probably treating your "dates" as strings.

这篇关于SQL 在日期之间选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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