简体   繁体   English

大于日期并等于另一个日期

[英]Greater than a date and Equal to a another date

I have a table where the table column as following date column data 我有一个表,其中表列如下日期列数据

   Date
----------
1900-01-01
1900-01-01
1900-01-01
2013-07-25
2012-07-25
2012-07-25
2013-07-25
2012-07-25
2013-07-25

Can I write a Query to filter date column which is equal to 1900-01-01 or greater than 2013-1-1 我可以写一个查询来过滤日期列等于1900-01-01或大于2013-1-1

Can I write a Query to filter date column which is equal to 1900-01-01 or greater than 2013-1-1 ? 我可以编写一个查询以过滤等于1900-01-01或大于2013-1-1的日期列吗?

Yes, you can, it's pretty much exactly as you phrased the question. 是的,可以,这几乎与您所说的问题完全一样。

Something like this should do the trick: 这样的事情应该可以解决问题:

select something from my_table
where date = '1900-01-01'
   or date > '2013-01-01'

If your condition is more complex than that, you can parenthesise the clause to keep it self-contained (no precedence rules mucking up your overall condition): 如果您的条件比这更复杂,则可以在该子句上加上括号以使其保持独立(没有优先规则会影响您的总体条件):

select something from my_table
where (date = '1900-01-01' or date > '2013-01-01')
  and blah blah blah

Try this, 尝试这个,

select data from Table where date=' 1900-01-01'
union all
select data from Table where date >'2013-1-1'

In SQL Server,You can use DATEDIFF function for comparing date values. 在SQL Server中,可以使用DATEDIFF函数比较日期值。

    SELECT col1,col2,.. FROM YourTable WHERE DATEDIFF(dd,date,'1900-01-01') = 0;

    UNION ALL 

    SELECT col1,col2,.. FROM YourTable WHERE DATEDIFF(dd,date,'2013-01-01') > 0;

暂无
暂无

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

相关问题 大于或等于日期 - Greater than or equal to a date 获取日期等于或大于 90 天前的数据 - Get data when date is equal to or greater than 90 days ago 如何选择日期大于另一行中日期的行? - How to select rows where date is greater than the date in another row? SQL:DATEDIFF如果开始日期大于另一个字段中的日期 - SQL: DATEDIFF If Start Date is greater than a date in another field 如果在“大于或等于”和“小于或等于”中使用相同的日期,where子句将失败 - Where clause fails if using same date in a “greater than or equal to” and a “less than or equal to” MySQL查询返回等于或大于特定日期的行,其中日期以年,月和日列分隔 - MySQL query to return rows that are equal to or greater than a certain date, where the date is separated in year, month and day columns 我无法在Sql中检索大于或等于特定日期的日期。 - I can't retrieve the Date greater than or equal to a specific date in Sql. 如果添加日期和当前日期之间的持续时间不大于或等于 2 小时,则获取数据 - Fetch a data if the time duration between added date and current date is not greater than or equal to 2 hours 如果选择的日期等于或大于数据中的日期,则日期之间的查询仅返回结果 - Query between dates only returns results if a selected date is equal or greater than date in data SQL Server datecolumn不能大于另一个日期列 - SQL Server datecolumn NOT greater than another date column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM