how to find between dates in sql server 2008? -
i give 2 different date input. want find, date between 2 date..
for eg:
1'st input : 2011-02-20 2'nd input : 2011-02-25 output is: 2011-02-20 2011-02-21 2011-02-22 2011-02-23 2011-02-24 2011-02-25
is there function find between date...
otherwise how find ?
you can use cte achieve this.
declare @startdate datetime declare @enddate datetime set @startdate = '2011-02-20' set @enddate = '2011-02-25' ;with getdates ( select 1 counter, @startdate date union select counter + 1, dateadd( day, counter, @startdate ) getdates dateadd( day, counter, @startdate ) <= @enddate ) select date getdates
Comments
Post a Comment