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)
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
第一个是时间段和时间段
第二个是时间段和时间点