HOW TO GET DAY OF THE WEEK IN MICROSOFT DYNAMICS AX
static void dayOfWkExample(Args _arg)
{
date d = today();
int i;
;
i = dayOfWk(d);
print "Today's day of the week is " + int2Str(i);
pause;
}
HOW TO GET DAY OF THE WEEK IN MICROSOFT DYNAMICS AX
static void dayOfWkExample(Args _arg)
{
date d = today();
int i;
;
i = dayOfWk(d);
print "Today's day of the week is " + int2Str(i);
pause;
}
|
Data type
|
Default
|
Internal representation
|
|
Boolean
|
false
|
Short number
|
|
Integer
|
0
|
Long number
|
|
Real
|
0.0
|
BCD (binary-coded digital) number
|
|
Date
|
Null
|
Date
|
|
String
|
empty
|
List of characters
|
|
Enums
|
0 (first entry)
|
Short number
|
|
Operator
|
Description
|
|
+ - *
|
If one of the operands is a real, the other will be
converted into real and the result is a real.
If both are integers, Booleans, or enums, no conversion
will take place, and the result will be integer, Boolean, or enum,
respectively.
Otherwise, a Boolean is promoted to enum and enum is
promoted to integer
|
|
/
|
Because / is division, the result can be decimal. X++
converts numbers to real before performing the division. The result is real.
|
|
ID
|
Expression
|
Left data type
|
Operands converted
|
With numbers
|
Result
|
|
1
|
i = b + b
|
integer
|
Boolean, Boolean
|
i = false + false
|
0
|
|
2
|
i = r + b
|
integer
|
real, real
|
i = 33.3 + true
|
34
|
|
3
|
b = i + r
|
Boolean
|
real, real
|
b = 10 + 33.3
|
undefined
|
|
4
|
b = i + r
|
Boolean
|
real, real
|
b = 0 + 1
|
true
|
|
5
|
r = i + b
|
real
|
integer, integer
|
r = 100 + false
|
100.0
|
|
6
|
r = i + b
|
real
|
integer, integer
|
r = 100 + true
|
101.0
|
|
7
|
i = r MOD b
|
integer
|
integer, integer
|
i = 33.3 MOD true
|
0
|
|
8
|
r = i DIV i
|
real
|
no conversion
|
r = 100 DIV 5
|
20
|
|
9
|
d = d + i
|
date
|
date, date
|
d = 1\1\1998 + 30
|
31\1\1998
|
|
10
|
i = d + i
|
integer
|
date, date
|
i = 1\1\1998 + 1
|
compile error
|
|
11
|
d = d + d
|
date
|
date, date
|
d = 1\1\1998+1\1\1998
|
compile error
|
|
12
|
s = s + s
|
string
|
string, string
|
s = "a" + "b"
|
"ab"
|
|
13
|
i = s + i
|
integer
|
|
ID
|
Discussion
|
|
2
|
The assignment i = r + b, with r = 33.3 and b = true is
calculated as follows:
X++
i = 33.3 + true; // Which is evaluated as... i = 33.3 + 1.0; // Which is evaluated as... i = 34.3; // Which is evaluated as... i = 34; // ...as i is an integer. |
|
3
|
The result is undefined because a Boolean has only two
legal values: false (0)
and true (1). The result of the expression 10
+ 33.3 is 43, which is assigned to the Boolean.
Note
Because
the internal representation is integer, you can use the Boolean in an
expression and it will represent the value 43. The Boolean will be considered true.
|
|
9
|
Shows that an integer can be added to a date. The
system treats the integer as a quantity of days.
Note
The utcdatetime data type does not support arithmetic
operations and implicit conversions. Instead, methods on the DateTimeUtil class can be used.
|
|
10
|
Results in a compiler error, because a date cannot be
automatically converted into an integer.
|
|
11
|
Shows that you cannot add dates together.
|
|
12
|
Shows that the + operator strings concatenates two strings to create a
new string.
|
|
13
|
Shows that there is no automatic conversion between
strings and integers (or other numbers). However, you can make explicit
conversions by using built-in conversion functions, such as the str2int function.
|
|
Type
|
Value treated as null
|
|
Date
|
1900-01-01
|
|
Enum
|
Element with its value set to 0.
|
|
Integer
|
0
|
|
Real
|
0.0
|
|
String
|
An empty string
|
|
Time
|
00:00:00
|
|
Utcdatetime
|
Any value with its date portion as 1900-01-01 is
treated as null,
regardless of the time portion value. Therefore the value 1900-01-01T22:33:44
is treated as null.
Note
Any utcDateTime value with its date portion as
1900-01-01 is displayed as blank by the X++ print statement. Only the value
1900-01-01T00:00:00 is displayed as blank by the Global::info method. That is the value from
the DateTimeUtil::MinValuemethod.
|