sqlserver between and
时间: 2023-08-16 15:08:25 浏览: 210
MSSQL SERVER中的BETWEEN AND的使用
在SQL Server中,使用BETWEEN和AND关键字来过滤DATETIME类型的查询语句时,需要在前后两个时间点都带上时分秒。例如,如果要查询字段field7在'2017-04-18'(开始时间)和'2017-04-20'(结束时间)之间的数据,查询的SQL语句应该是:
SELECT * FROM table_name
WHERE field7 BETWEEN '2017-04-18 00:00:00' AND '2017-04-20 23:59:59';
这样可以确保查询结果包括开始时间和结束时间这两个时间点的数据。\[1\]\[2\]
#### 引用[.reference_title]
- *1* *3* [SQL SERVER之BETWEEN……AND……](https://blog.csdn.net/jsjyuchengyong/article/details/18266135)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [解决SQL Server中between and数据不包含的问题](https://blog.csdn.net/wjiaoling136/article/details/84895651)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文