Drop Table
Support Forum for database administrators and web based access to important newsgroups related to databasesIs 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,@d2,@d1 )> 0) then @d2 else @d1 end Cheers,.. N
Post Follow-up to this messageTry: SELECT CASE WHEN @d1<@d2 THEN @d1 ELSE COALESCE(@d2,@d1) END or: SELECT MIN(dt) FROM (SELECT @d1 UNION ALL SELECT @d2)T(dt) -- David Portas SQL Server MVP --
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread