SQL 列出特定日期之后的行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9532668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 14:38:00  来源:igfitidea点击:

List rows after specific date

sqlsql-serversql-server-2008sql-server-2005

提问by Baz

I have a column in my database called "dob" of type datetime. How do I select all the rows after a specific DoB in SQL Server 2005?

我的数据库中有一个名为“dob”的日期时间列。如何在 SQL Server 2005 中选择特定 DoB 之后的所有行?

回答by cgatian

Simply put:

简单的说:

SELECT * 
FROM TABLE_NAME
WHERE
dob > '1/21/2012'

Where 1/21/2012 is the date and you want all data, including that date.

其中 1/21/2012 是日期,您需要所有数据,包括该日期。

SELECT * 
FROM TABLE_NAME
WHERE
dob BETWEEN '1/21/2012' AND '2/22/2012'

Use a between if you're selecting time between two dates

如果您选择两个日期之间的时间,请使用 between