簡體   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