Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

sql get latest of 2 datetimes

SELECT ID,
       CASE WHEN 
              COALESCE(Date1, '1/1/1973') > COALESCE(Date2, '1/1/1973') -- COALESCE is to ensure comparison works when 1 is nullable
         THEN Date1
         ELSE Date2
       END AS MostRecentDate
FROM Table
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sql #latest #datetimes
ADD COMMENT
Topic
Name
4+8 =