Relational Operators [AX 2012]
Updated: September 23, 2011
Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
The following table lists the relational operators that can be used in X++. All relational operators (except !) are placed between two expressions: expression1 relationalOperator expression2. For example, while (a > 10).
Operator 
Meaning 
Description 

like 
like 
Returns true if expression1 is like expression2. like can use * as a wildcard for zero or more characters and ? as a wildcard for one character. Expression2 cannot be longer than 1000 characters. If the expressions that you are comparing contain a file path, you need to include four backslashes between each element. For example: select * from xRefpaths where xRefPaths.Path like “\\\\Classes\\\\AddressSelectForm” Note like is evaluated by the underlying SQL, so the result may differ on different installations.

== 
equal 
Returns true if both expressions are equal. Note
When you use == to compare objects, the object references rather than the objects themselves are compared. This may be a problem if you compare two objects that are located on the server and on the client, respectively. In such cases, you should use the equal method in the Object class, which you can override to specify what it means that two objects are equal. If equal is not overridden, the comparison is identical to the one performed by ==.

>= 
greater than or equal to 
Returns true if expression1 is greater than or equal to expression2. 
<= 
less than or equal to 
Returns true if expression1 is less than or equal to expression2. 
> 
greater than 
Returns true if expression1 is greater than expression2. 
< 
less than 
Returns true if expression1 is less than expression2. 
!= 
not equal 
Returns true if expression1 is different from (that is, not equal to) expression2. 
&& 
and 
Returns true if both expression1 and expression2 are true. 
 
or 
Returns true if expression1 or expression2 or both are true. 
! 
not 
A unary operator. Negates the expression. Returns true if the expression is false; false if the expression is true. 
Operator 
Example 
Returns 

like 
"Jones" like "Jo?es" 
true; the ? is equal to any single character. 
like 
"Fabrikam, Inc." like "Fa*" 
true; the * is equal to zero or more characters. 
== 
(( 42 * 2) == 84) 
true; 42*2 is equal to 84. 
>= 
today() >= 1\1\1980 
true; today is later than January 1, 1980. 
>= 
((11 div 10) >= 1) 
true; 11 div 10 is 1 (therefore, >= 1 is true). 
<= 
(11<= 12) 
true; 11 is less than 12. 
> 
((11 div 10) > 1) 
false; 11 div 10 is 1. 
< 
(11 div 10) < 1) 
false; 11 div 10 is 1. 
!= 
(11 != 12) 
true; 11 is not equal to 12. 
&& 
(1 == 1) && (3 > 1) 
true; both expressions are true. 
Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. get your copy at the MS Press Store