The <, >, <=, >=, =, and <> operators can compare number-, date-, time period-, or text-formatted items (The = and <> operators can also compare Boolean-formatted items). The behavior of each operator varies based on the data type compared.
When you use a comparison operator to compare numeric items, it considers the number that is closer to positive infinity as greater. For example, this means that 1 is greater than -1,000,000,000.
Date and time period comparison
When you use a comparison operator to compare date- or time period-formatted values, it considers the later date as greater.
You cannot compare a date- and time period-formatted value as they are not the same data type. If you need to, convert between data types.
The comparison of text-formatted items follows lexicographical order. As such, when a comparison operator compares text-formatted values, it considers strings with fewer characters as greater than strings with more.
For two strings of equal length, the operator compares the first character that differs from left to right to determine which string has a greater value. The types of character and criteria below, in order, give a text string a greater value if they're the first character that differs:
- Special characters used in non-English languages
- Capitalization (capitals > lowercase)
- Alphabetical order (a > z)
- Special characters such as punctuation
- Numeric order (0 > 9)