# Choosing a date based on multiple criteria

#### omf_24

##### New Member

If the code is 03, 04, or 05, I want the result to be the later date of Date 3 or Date 2, otherwise I would want the earlier date to appear. If both are blank then Date 1 should be used.

 Code Date 1 Date 2 Date 3 Result A1 6/11/2013 2/5/2014 3/15/2013 3/15/2013 05 6/25/2013 1/17/2014 5/21/2014 5/21/2014 04 11/13/2012 11/13/2012 07 12/18/2012 1/17/2013 1/17/2013

<tbody>
</tbody>

### Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

#### ztodd

##### Board Regular
untested:
=if(and(c2="",d2=""),b2,if(or(a2="03",a2="04",a2="05"),max(d2,c2),min(d2,c2)))

#### ProfessorPorcupine

##### Board Regular
Try this, it is pretty long but I think it works ok: =IF(AND(C3=0,D3=0),B3,IF(OR(A3="03",A3="04",A3="05"),IF(D3>C3,D3,C3),IF(AND(C3<B3,C3<>0),C3,IF(AND(D3<C3,D3<>0),D3,C3))))

#### omf_24

##### New Member
untested:
=if(and(c2="",d2=""),b2,if(or(a2="03",a2="04",a2="05"),max(d2,c2),min(d2,c2)))

Thanks, this is working great if the code is 03, 04, or 05, but not if it's anything other than 03, 04, or 05. In that case it should be returning the earlier date rather than the later date.

#### omf_24

##### New Member

Try this, it is pretty long but I think it works ok: =IF(AND(C3=0,D3=0),B3,IF(OR(A3="03",A3="04",A3="05"),IF(D3>C3,D3,C3),IF(AND(C3<b3,c3<>0),C3,IF(AND(D3<c3,d3<>0),D3,C3))))

Sorry, but why cell's C30, and D30? </c3,d3<></b3,c3<>

#### omf_24

##### New Member
Thanks, this is working great if the code is 03, 04, or 05, but not if it's anything other than 03, 04, or 05. In that case it should be returning the earlier date rather than the later date.

Sorry, this is working correctly, thanks again!

#### ztodd

##### Board Regular
you're welcome.

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,164,116
Messages
5,835,476
Members
430,358
Latest member
zzc1128

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back