Sunday, 9 July 2023

Primitive Data types

 

Primitive Data Types

The primitive data types in X++ are listed in the following table. For more information about each data type, click its link.

Anytype

A placeholder for any data type.

Booleans

The boolean data type contains a value that evaluates to either true or false. You can use the X++ reserved literals true and false where ever a Boolean expression is expected.

Dates

Contains day, month, and year. The date data type can hold dates in the closed interval [1\1\1900; 31\12\2154], that is: between January 1, 1900, and December 31, 2154.

Enums

An abbreviation for enumerated text—a set of literals. Enum values are represented internally as integers. The first literal has number 0, the next has number 1, the next has number 2, and so on. You can use enums as integers in expressions.

 

Integers

A number without a decimal point. To declare an integer, use the keyword int.

Integers are numbers without decimals. X++ has two integer types:

  • int, which is 32 bits wide
  • int64, which is 64 bits wide

 

Reals

Numbers with a decimal point; also called decimals.

Strings

A number of characters. To declare a string, use the keyword str.

Strings are sequences of characters that are used as texts, help lines, addresses, telephone numbers, and so on. To declare a string in X++, use the str keyword.

A string can hold an indefinite number of characters. If you know the absolute maximum of characters a string will hold, you can specify this in the variable declaration and force a truncation to the maximum length of the string.

TimeOfDay

Contains hours, minutes, and seconds. To declare a time, use the system type timeOfDay.

utcdatetime

Contains year, month, day, hour, minute and second.

 

The utcdatetime data type is intrinsic to X++. It combines date and timeOfDay types into one type. A utcdatetime variable also holds time zone information, though this information is not accessible to X++ code.

Range and Precision


The following table describes the range and precision of the utcdatetime data type.

Attribute of utcdatetime

Description

Precision

The smallest unit of time in utcdatetime is one second.

Default and Null

1900-01-01T00:00:00

A utcdatetime variable that has been declared but not initialized has the default value of 1900-01-01T00:00:00. This is the value returned by DateTimeUtil ::minValue().

Some functions treat an input parameter of this minimum value as null. For instance, the DateTimeUtil ::toStr method returns an empty string, however, the DateTimeUtil ::addSeconds method returns a fully usable utcdatetime value.

Minimum Value

1900-01-01T00:00:00

Maximum Value

2154-12-31T23:59:59

This matches the upper range of date and timeOfDay.

 

 

No comments:

Post a Comment

Data Entities in D365 FnO

  Data management - Data entities ·        Data entity is a conceptual abstraction and encapsulation of one of more underlying tables. ...