在DateTime字段中的两个日期之间进行选择 - SQL Server

时间:2022-10-14 15:42:57

How to select records between a date to another date given a DateTime field in a table.

如何在给定表中的DateTime字段的日期与另一个日期之间选择记录。

2 个解决方案

#1


16  

SELECT * 
FROM tbl 
WHERE myDate BETWEEN #date one# AND #date two#;

#2


5  

select * 
from blah 
where DatetimeField between '22/02/2009 09:00:00.000' and '23/05/2009 10:30:00.000'

Depending on the country setting for the login, the month/day may need to be swapped around.

根据登录的国家/地区设置,可能需要交换月/日。

#1


16  

SELECT * 
FROM tbl 
WHERE myDate BETWEEN #date one# AND #date two#;

#2


5  

select * 
from blah 
where DatetimeField between '22/02/2009 09:00:00.000' and '23/05/2009 10:30:00.000'

Depending on the country setting for the login, the month/day may need to be swapped around.

根据登录的国家/地区设置,可能需要交换月/日。