SQL 两个时间段 不能重复语句

 1 DECLARE @BeginDate datetime;
 2 DECLARE @EndDate datetime;
 3 set @BeginDate='2015-03-2'
 4 set @EndDate='2015-03-2'
 5 SELECT * FROM Table
 6 where 
 7 (BeginDate between @BeginDate and @EndDate) or
 8 (EndDate between @BeginDate and @EndDate) or 
 9 (@BeginDate between BeginDate and EndDate) or 
10 (@EndDate between BeginDate and EndDate)              
View Code
1 DECLARE @BeginDate datetime;
2 DECLARE @EndDate datetime;
3 set @BeginDate='2014-03-2'
4 set @EndDate='2015-06-2'
5 SELECT * FROM Table    
6 where 
7 @BeginDate<=Date and 
8 Date <=@EndDate
9 order by Date 

第一个是时间段和时间段  

第二个是时间段和时间点

posted @ 2017-08-24 11:49  老-顾  阅读(823)  评论(0编辑  收藏  举报