Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

daterange

$
0
0

I'm executing the below code i'm getting output as  below. 


DateFromDateTo
2014-01-01 00:00:00.0002014-01-20 23:59:59.000 

But why i'm missing

2014-01-21 00:00:00.000','2014-12-31 23:59:59.000'

DECLARE @TABLE TABLE(DateFrom DATETIME, DateTo DATETIME)

INSERT INTO @TABLE
SELECT '2012-01-01 00:00:00.000','2012-12-31 23:59:59.000' UNION ALL 
SELECT '2013-01-01 00:00:00.000','2013-12-31 23:59:59.000' UNION ALL 
SELECT '2014-01-01 00:00:00.000','2014-01-20 23:59:59.000' UNION ALL 
SELECT '2014-01-21 00:00:00.000','2014-12-31 23:59:59.000'
Declare @startdate datetime ='2014-01-01',
          @Enddate datetime = '2014-01-31'
SELECT * from @TABLE where( DateFrom>=@startdate AND DateTo<=@EndDate)





Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>