Microsoft Access - How to compare 2 date fields in a query to show the most current date

Asked By Patrick Fortier on 28-Mar-14 03:22 AM
I've set-up a query pulling dates from 2 different tables (Date1 & Date2). 

How can I compare the 2 date columns and have it spit out the most current date in a third column?  

Example:

Date1 (Column 1) - 03/21/2014
Date2 (Column 2) - 04/03/2026

Date3 (Column 3) - Should report 04/03/2026

Note: Date1 or Date 2 could be more current. 

Thanks
Robbe Morris replied to Patrick Fortier on 28-Mar-14 08:36 AM
I believe you using the switch function in Microsoft Access.  Similar to SELECT CASE

http://stackoverflow.com/questions/15774078/is-it-possible-to-using-select-case-statement-in-access-query
Pat Hartman replied to Patrick Fortier on 30-Oct-14 01:14 PM

For simple conditions, you can use the IIf() function which is the Access SQL equivalent of the CASE statement.


Select fld1, fld2, fld3, IIf(Date1 > Date2, Date1, Date2) As Date3, fld4 From your table.