sql get latest of 2 datetimes

Solutions on MaxInterview for sql get latest of 2 datetimes by the best coders in the world

showing results for - "sql get latest of 2 datetimes"
Oscar
06 Sep 2017
1SELECT ID,
2       CASE WHEN 
3              COALESCE(Date1, '1/1/1973') > COALESCE(Date2, '1/1/1973') -- COALESCE is to ensure comparison works when 1 is nullable
4         THEN Date1
5         ELSE Date2
6       END AS MostRecentDate
7FROM Table