Formula help with using date.

omairhe

Well-known Member
Joined
Mar 26, 2009
Messages
2,040
Office Version
  1. 2019
Platform
  1. Windows
Hello all,

How can I write this formula to consider the first 7 characters as dates in cells D9 and D10 ?

=IF(LEFT(D9,7)=LEFT(D10,7),"A",IF(LEFT(D9,7)>LEFT(D10,7),"B",IF(LEFT(D9,7)<LEFT(D10,7),"C")))

D9 =
03-2021 (user.one).xlsb

D10 =
03-2021 (user.two).xlsb

answer = A


D9 =
04-2021 (user.one).xlsb

D10 =
03-2021 (user.two).xlsb

answer = B


D9 =
05-2020 (user.one).xlsb

D10 =
04-2021 (user.two).xlsb

answer = C

Thanks and will appreciate.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
You are seeing if two text strings match. That works. Why does it matter if the represent dates or something else? Your formula is not trying to use them as dates.
 
Upvote 0
You are seeing if two text strings match. That works. Why does it matter if the represent dates or something else? Your formula is not trying to use them as dates.

There are three conditions to match. 1st is to check if both the dates are equal, then output A, but for the other two conditions the greater than and less than is required to output either B or C.
The values are in text becuase of the hyphen - in between the month and the year. Plus, in order to make this work it will have to recognize the years first and then the months.
For instance 03-2021 and 04-2020 will make 04-2020 greather than 03-2021. whereas it should be the other way around.
If 2021-03 and then 2020-04 will then give the correct answer, that is if the hypen was not included. And the text was considered as a number for greater than and less than to work. Or like my original post suggested, for the formula to condider it as a date.
 
Upvote 0
The requirement has slightly changed and carried forward to the given link. Thank you.

 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top