Finding the Later of 2 Date fields in a query to make a 3rd Datefield

B

bobdydd

Hi All

I have a query based on a single Table the has the
following fields:
Field 1: BoughtDate
Field 2: SoldDate

Sometimes the SoldDate is earlier than the BoughtDate

What I am trying to do is put the LATER one of
these 2 date fields in a 3 date field called:
LastTradeDate:

Any ideas?

Regards
Bob
 
F

Filio

I think you can just do a quick comparison in an IIF statement to
populate the third date field, like this:

SELECT Table1.BoughtDate, Table1.SoldDate, IIf([BoughtDate]>[SoldDate],
[BoughtDate],[SoldDate]) AS LastTradeDate
FROM Table1;

Here are my results:

BoughtDate SoldDate LastTradeDate
10/1/2007 11/1/2007 11/1/2007
12/1/2007 11/25/2007 12/1/2007
10/2/2007 10/3/2007 10/3/2007
10/1/2007 9/29/2007 10/1/2007
10/1/2007 8/28/2007 10/1/2007
8/31/2007 9/4/2007 9/4/2007

I hope that helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top