Is there a more elegant way to do the following?...
declare @d1 datetime, @d2 datetime
set @d1 = '2005-01-01'
set @d2 = '2005-02-01'
select
case
when datediff(dd,@d2 ,@d1)is null
then coalesce(@d1, @d2)
when (datediff(dd,@d 2,@d1)> 0)
then @d2
else @d1
end
Cheers,..
N
declare @d1 datetime, @d2 datetime
set @d1 = '2005-01-01'
set @d2 = '2005-02-01'
select
case
when datediff(dd,@d2 ,@d1)is null
then coalesce(@d1, @d2)
when (datediff(dd,@d 2,@d1)> 0)
then @d2
else @d1
end
Cheers,..
N
Comment