Compare two dates in a table and return the greater using SQL Server

Compare two dates in a table and return the greater using SQL Server

We can get and return using CASE statement in SQL Server. i.e.

CASE
   WHEN STARTDATE >= ENDDATE
       THEN STARTDATE
   ELSE ENDDATE

END


The example in detail as given below.


SELECT
            EXCEPTIONID,
            (CASE
               WHEN INSERTEDDATE >= UPDATEDDATE
                           THEN INSERTEDDATE
               ELSE UPDATEDDATE
            END) AS EXCEPTION_DATE

FROM [DBO].[APPEXCEPTION]


ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Google Amazon and Flipkart Book Store!

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.
ASK Questions
SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book