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
Can I write a Query to filter date column which is equal to 1900-01-01 or greater than 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.
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.