# Tom’s Tutorials For Excel: Lookup Oldest and Newest Date

Tom’s Tutorials For Excel: Lookup Oldest and Newest Date

The picture shows one way of obtaining the oldest and newest dates in column B that correspond to the person’s name in column A that is in cell D2 as a lookup criteria. Because dates are numbers, you can use the `MIN` function for the oldest date, and the `MAX` function for the newest date.

The formula in cell E2 for the oldest date is `=MIN(IF(A2:A26=D2,B2:B26))`.
The formula in cell F2 for the newest date is `=MAX(IF(A2:A26=D2,B2:B26))`.

Array formulas are committed to a cell by pressing Ctrl+Shift+Enter, not just Enter.

###### 22 comments on “Tom’s Tutorials For Excel: Lookup Oldest and Newest Date”
1. sumit majumder says:

I need a details in excel that if i put an unique code than it will retrieve last date of visit excluding the current date & if unique code row is blank than return 0

A B
Reg. No Date
1000 17-Jan-18
1000 17-Jun-18
And if i put 1000 in A4 than result will come in C4 is 17-Jun-18

• Tom Urtis says:

`=IF(LEN(A4)=0,"",MAX(0,MAX(IF(A2:A3=A4,B2:B3))))`

This is an array formula, applied to a cell with `Ctrl+Shift+Enter`, NOT just with `Enter`.

2. sujit says:

how to find second min date and max date up to n …. numbers date

3. sujit says:

Hi Tom

tome 1st oldest date and newest date find that is (feb17,2011 and july09,2011) similar what about tome 2nd oldest date and newest date and which formula use to fined 3rd, 4th…..n number of Oldest and newest date to find.

• Tom Urtis says:

You can use this formula:
=LARGE(A1:A100,2) for the second largest (oldest)
=LARGE(A1:A100,3) for the third largest (oldest)
and so on.

4. Bryan says:

Thank you! Just what I was looking for.

5. Melissa says:

Hello, could you tell me what the formula is to look for the minimum date in a range but that particular date has to be after a certain date?

• Tom Urtis says:

With dates in range A2:A14 and an “after date” in cell C1, this array formula (Ctrl+Shift+Enter) should do what you want:
=MIN(IF(A2:A14>C1,A2:A14))

6. MMurphy says:

Hello,

What if I need to have the formula provide the value in D2(all unique values in column A) because there are too many to enter individually (as you have TOM listed in D2). I want the formula to provide the unique values from column A into my column D, rather than me manually inputting it. If that makes sense.

• Tom Urtis says:

Well, no, it does not exactly make sense because you wrote
“I want the formula to provide the unique values from column A into my column D”
when column D only shows in cell D2 what you want to find in column A.

I do not know what you want, maybe a unique list of names from column A to be listed somewhere, but in any case, more detail from you can help me understand what you want to end up with.

7. Pam Stazesky says:

Hi Tom,
How do you will down the column to get the oldest date for each person such as Bill, Bob, Mike, etc.? I know these names must be added to column D. I’m sure this simple, but I cannot figure it out. I just get my answer for my first line (Tom), but it puts Tom’s date for every single person.

• Tom Urtis says:

It could be done with a pivot table but to do it by a formula, actually two formulas, here are two pictures.

In the top picture, to list the unique names of people in column D the array formula in cell G2 and copied down as needed is
`=INDEX(\$D\$2:\$D\$18,MATCH(0,COUNTIF(\$G\$1:G1,\$D\$2:\$D\$18),0))`
And for anyone wondering, yes I know, Advanced Filter can do this too, but I used an array formula in this case because I felt like it.

In the bottom picture, to return each unique person’s oldest date, the array formula in cell H2 and copied down is
`=MIN(IF(\$D\$2:\$D\$18=G2,\$E\$2:\$E\$18))`
To get the newest date instead of the oldest date, simply change the `MIN` to `MAX`.
And for anyone wondering, yes I know about XLOOKUP, but I used an array formula in this case because I felt like it again.

Recall that these are array formulas. You apply them with `Ctrl+Shift+Enter`, not just with `Enter`.

8. Richard says:

Hi Tom, great tip, thanks. Sorry for the late response to the thread (I’m new to the site). Is it possible amend the formula to pull the earliest date from a series of rows, if the data is continuous? Our system spits out a new row of data after any amendments to records, I’m often asked when the latest allowance first started. Example below:

Ideally, I’d like to pull 01/06/2021 for row 1-3, and 01/01/2018 for row 4-5. Any help would be appreciated, even multiple column possibilities.

Staff Member Start Date End Date Type Continous Date
12345 01/12/2021 20/05/2022 Hardship
12345 02/08/2021 30/11/2021 Hardship
12345 01/06/2021 01/08/2021 Hardship
12345 01/01/2019 30/04/2019 Hardship
12345 01/01/2018 31/12/2018 Hardship

• Tom Urtis says:

I do not understand how you want the results to look. In my example I show a range that listed the criteria by count. You need to show what your expected result looks like and why it looks the way it looks.

9. Richard says:

Hi Tom, unfortunately I can’t add a picture with this on so it is hard to show. In the final column, row 2-4 would show 01/06/2021 for the start of the second continuous block, row 5-6 would show 01/01/2018

• Tom Urtis says:

There are too many ambiguous possibilities such as the varying count of columns and what dates constitute what cut-offs.

I suggest you post your question on a superb forum for Excel which I am a longtime contributor to. You can post a picture there, it is free and easy and no spam, with experts around the clock who can assist.
https://www.mrexcel.com/board/forums/excel-questions.10/

10. Binsar says:

Could you help me please, i want the result is the nearest older date or if there is the date there, then the result is that date. here is my data:

A (Data)
01/01/23
05/01/23
12/01/23
31/01/23

B (Input)
11/01/23

C (Formulated Result)
05/01/23
=IF(B1=A1:A4;A1:A4;MAX(IF(\$A\$1:\$A\$4<B1;\$A\$1:\$A\$4)))

It works for the date that are not in the data, but if i input 12/01/23, the result is still 05/01/23, and i want the result is 12/01/23. Please help. Thanks Tom!

• Tom Urtis says:

And when I enter 13/1/2023 in cell B1 the formula returns 12/01/23 as it should.

Maybe you are not confirming the formula in cell C1 with Ctrl+Shift+Enter instead of just Enter

or

Maybe you are entering the 12/01/23 in maybe cell A5 which is outside of the range of cells in your formula.

Whatever the case is, I cannot duplicate your problem. It works for me.

• Binsar says:

Dear Mr. Tom,

Yes it works if you input the date that doesn’t in the data (it will show the nearest oldest one). But i want the result if there is the date there (A1:A4), it will result the data instead.

Here are the result i want:
B1 (Input)
11/01/23
C1 (Formulated)
05/01/23

B1 (Input)
12/01/23
C1 (Formulated)
12/01/23

It seems the formula =IF(B1=A1:A4;A1:A4; doesnt work with MAX(IF(\$A\$1:\$A\$4<B1;\$A\$1:\$A\$4))). Because if i only use formula =IF(B1=A1:A4;A1:A4;, it works for show the data, but if i add MAX(IF(\$A\$1:\$A\$4<B1;\$A\$1:\$A\$4))) on the False Value on IF, it only reads the MAX(IF(\$A\$1:\$A\$4<B1;\$A\$1:\$A\$4))).

Looking forward for your help Mr. Tom, Tks.

• Tom Urtis says:

As I said, the formula and what you say you want all works for me.
This makes no sense:
“that doesn’t in the data”
I say again which you have not confirmed, if you are applying the formula with Ctrl+Shift+Enter, NOT JUST with Enter.