[英]date query between two dates
在我的表中我有这个架构
record startDate endDate
abs 2005-11-29 2005-11-21
absasd 2005-11-23 2005-01-22
absty 2005-10-26 2005-02-23
absfx 2005-09-27 2005-09-24
absft 2005-10-28 2005-07-25
absyh 2005-01-28 2005-08-01
absdx 2005-12-29 2005-01-02
abs345 2005-06-24 2005-02-03
abser 2005-07-14 2005-04-06
absbv 2005-08-01 2005-05-08
abse 2005-07-12 2005-06-09
abserr 2005-12-30 2005-07-14
absf 2005-01-12 2005-12-16
abscv 2005-04-11 2005-12-26
abscv 2005-06-01 2005-11-27
absc 2005-07-03 2005-10-28
absv 2005-07-06 2005-09-25
.....
.....
......
我想 select 属于 2005-01-01 和 2005-10-01 之间的所有记录。 和某些其他日期。 sql 是什么。
SELECT *
FROM YourTable
WHERE startDate >= '2005-01-01'
AND endDate <= '2005-10-01'
拥有 1K+ 的声誉和这个问题? 你还好吗? :-)
SELECT * FROM TableName
WHERE startDate > '2005-01-01' and startDate < '2005-10-01'
--WHERE startDate > '2005-01-01' and endDate < '2005-10-01'
--WHERE endDate > '2005-01-01' and endDate < '2005-10-01'
--WHERE endDate > '2005-01-01' and startDate < '2005-10-01'
--WHERE (startDate > '2005-01-01' and startDate < '2005-10-01' ) OR (endDate > '2005-01-01' and endDate < '2005-10-01')
--WHERE (startDate > '2005-01-01' and startDate < '2005-10-01' ) AND (endDate > '2005-01-01' and endDate < '2005-10-01')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.