[英]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.