Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

PREVIOUS NEXT
Code Example
Sql :: mybatis batch update oracle 
Sql :: dbname+tablename 
Sql :: how to fetch highest score in minimum time using mysql 
Sql :: sql alchemy escape ; in insert statement 
Sql :: from weeknumber to date 
Sql :: mysql_error replacement 
Sql :: Bigquery insert issue 
Sql :: sql select in where clause for when more than one records exists 
Sql :: ORA-32794: cannot drop a system-generated sequence 
Sql :: codeigniter MySQL - Issue with SELECT & GROUP BY 
Sql :: SQL Manipulação de Tabelas Constraint 
Sql :: in query in sql 
Sql :: SQL server datetime compare 
Sql :: while in plsql 
Sql :: How to display top 50 rows? 
Sql :: delete in sql server 
Sql :: finding leap year in sql 
Sql :: data structures in sql 
Sql :: how to Activate the database 
Csharp :: how to lock and hide a cursor unity 
Csharp :: c# yes or no dialog 
Csharp :: c# gzip byte array 
Csharp :: c# math to radiant 
Csharp :: c# bytes to string 
Csharp :: Getting data from selected datagridview row and which event 
Csharp :: c# random enum 
Csharp :: asp.net core .gitignore 
Csharp :: dotnet build to exe 
Csharp :: c# copy to clipboard 
Csharp :: how to change the title of the console in c# 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =