query the latest date out of two?

  • Thread starter Thread starter matjcb
  • Start date Start date
M

matjcb

I have a table with two dates

I would like to query the latest date of the two.

Date 1 Date 2 have it return
07/01/08 08/01/08 08/01/08

Thanks
 
If you mean you want to return the latest date

Field: IIF([Date 1] > [Date 2],[Date 1],[Date 2])

That does run into a bit of a problem if one of the two is null. To handle
that possibility you could use

IIF(Nz([Date 1],#1/1/1850#) > Nz([Date 2],#1/1/1850#),[Date 1],[Date 2])



John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
A slightly simpler expression for handling null dates.

IIF([Date 1] > [Date 2],[Date 1],Nz([Date 2],[Date 1])

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

John said:
If you mean you want to return the latest date

Field: IIF([Date 1] > [Date 2],[Date 1],[Date 2])

That does run into a bit of a problem if one of the two is null. To
handle that possibility you could use

IIF(Nz([Date 1],#1/1/1850#) > Nz([Date 2],#1/1/1850#),[Date 1],[Date 2])



John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
I have a table with two dates

I would like to query the latest date of the two.

Date 1 Date 2 have it return 07/01/08 08/01/08
08/01/08

Thanks
 
Back
Top