Can someone provide a reference to how excel compares strings using inequality operators in Excel? I have found some unexpected behavior:
In the below examples, the first two columns are strings, column C is of the expression =A2<B2
, the third column is the expected behavior, and the final column is whether the expected behavior matches the actual.
Comparison Benchmark Is A < B? Expected Pass?
Q1 2009 Q4 2012 TRUE TRUE TRUE
Q2 2009 Q4 2012 TRUE TRUE TRUE
Q3 2009 Q4 2012 TRUE TRUE TRUE
Q4 2009 Q4 2012 TRUE TRUE TRUE
Q1 2010 Q4 2012 TRUE TRUE TRUE
Q2 2010 Q4 2012 TRUE TRUE TRUE
Q3 2010 Q4 2012 TRUE TRUE TRUE
Q4 2010 Q4 2012 TRUE TRUE TRUE
Q1 2011 Q4 2012 TRUE TRUE TRUE
Q2 2011 Q4 2012 TRUE TRUE TRUE
Q3 2011 Q4 2012 TRUE TRUE TRUE
Q4 2011 Q4 2012 TRUE TRUE TRUE
Q1 2012 Q4 2012 TRUE TRUE TRUE
Q2 2012 Q4 2012 TRUE TRUE TRUE
Q3 2012 Q4 2012 TRUE TRUE TRUE
Q4 2012 Q4 2012 FALSE FALSE TRUE
Q1 2013 Q4 2012 TRUE FALSE FALSE
Q2 2013 Q4 2012 TRUE FALSE FALSE
Q3 2013 Q4 2012 TRUE FALSE FALSE
Q4 2013 Q4 2012 FALSE FALSE TRUE
Q1 2014 Q4 2012 TRUE FALSE FALSE
Q2 2014 Q4 2012 TRUE FALSE FALSE
Q3 2014 Q4 2012 TRUE FALSE FALSE
For dates before the benchmark, it seems like Excel compares the whole string, whereas after the benchmark date, Excel only compares the string until it finds a single character less than the analogous character in the comparison.