繁体   English   中英

如何在 SQL Server 中的 DATETIME 列上查询 DATE?

[英]How to query on DATE on DATETIME Column in SQL Server?

这是我的表,其中包含带有datetime字段的列( completed_on )。 但是我只需要根据date过滤结果。

SELECT * FROM myTable
WHERE completed_on 
-- Pass Date Range in condition

在此处输入图片说明

请提这个

SELECT * FROM myTable
WHERE completed_on BETWEEN 'date1' and 'Date2'
-- Pass Date Range in condition

另一种选择是——

SELECT * FROM myTable
WHERE completed_on >= '20190701' --Sample start Date 
and completed_on < '20190722' 
-- This will make sure dates will be inclued less then 
-- the given date. You have to pass this with 
-- understanding what you want. If you want 
-- date 7 to be included, please set the end date to 8 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM