hi Experts,
Could you Please help me on this query..
I have @startdate ='2012-01-01 00:00:00.000', @Enddate = '2014-01-31 00:00:00.000'
in the table i have dateranges define if the startdate and endate falls in the selected daterange of values in table then i should get the values of the table .
OUTPUT
2012-01-01 00:00:00.0002012-12-31 23:59:59.000
2013-01-01 00:00:00.000
2013-12-31 23:59:59.000
2014-01-01 00:00:00.000
2014-01-20 23:59:59.000
2014-01-21 00:00:00.000
2014-12-31 23:59:59.000
If @startdate ='2014-01-01 00:00:00.000', @Enddate = '2014-01-31 00:00:00.000' then
OUTPUT
2014-01-01 00:00:00.000 2014-01-20 23:59:59.000
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' SELECT * from @TABLE