Search code examples
exceldatesearchcompareformula

How to compare two dates in a text string in excel?


I have a set of data with this format: Each cell has one or some names, each of them are followed by a date. I want to compare the dates which are presented in each cell and check whether they are the same or not.

Example of a cell content: university XXX (2016-10-21) company YYY (2016-10-22)

example

I used the formula: =MID(A1,SEARCH("(",A1,1)+1,10) to find the first date. how could I find 2nd, 3rd, ... dates?

Thank you in advance,


Solution

  • Easiest if done step by step:
    So break down your MID(A1,SEARCH("(",A1,1)+1,10) (and make it more specific to dates - you don't want to match "(KACST)") as:
    B1: =SEARCH("(2",A1,1) and H1: =mid(A1,B1+1,10)
    Then add
    C1: =SEARCH("(2",A1,B1+1) This tells the search to start from the character after the one it has already found
    I1: =mid(A1,C1+1,10)
    etc