This page explains the data types in APL.
Axiom Processing Language supplies a set of system data types that define all the types of data that can be used with APL.
The following table lists the data types supported by APL, alongside additional aliases you can use to refer to them.
Type | Additional name(s) | gettype() |
---|---|---|
bool() | boolean | int8 |
datetime() | date | datetime |
dynamic() | array or dictionary or any other of the other values | |
int() | int has an alias long | int |
long() | long | |
real() | double | real |
string() | string | |
timespan() | time | timespan |
The bool (boolean) data type can have one of two states: true
or false
(internally encoded as 1 and 0, respectively), as well as the null value.
The bool data type has the following literals:
The bool
data type supports the following operators: equality (==
), inequality (!=
), logical-and (and
), and logical-or (or
).
The datetime (date) data type represents an instant in time, typically expressed as a date and time of day. Values range from 00:00:00 (midnight), January 1, 0001 Anno Domini (Common Era) through 11:59:59 P.M., December 31, 9999 A.D. (C.E.) in the Gregorian calendar.
Literals of type datetime have the syntax datetime (value
), where a number of formats are supported for value, as indicated by the following table:
Example | Value |
---|---|
datetime(2019-11-30 23:59:59.9) datetime(2015-12-31) | Times are always in UTC. Omitting the date gives a time today. |
datetime(null) | Check out our null values |
now() | The current time. |
now(-timespan) | now()-timespan |
ago(timespan) | now()-timespan |
now() and ago() indicate a datetime
value compared with the moment in time when APL started to execute the query.
We support the ISO 8601 format, which is the standard format for representing dates and times in the Gregorian calendar.
Format | Example |
---|---|
%Y-%m-%dT%H:%M:%s%z | 2016-06-26T08:20:03.123456Z |
%Y-%m-%dT%H:%M:%s | 2016-06-26T08:20:03.123456 |
%Y-%m-%dT%H:%M | 2016-06-26T08:20 |
%Y-%m-%d %H:%M:%s%z | 2016-10-06 15:55:55.123456Z |
%Y-%m-%d %H:%M:%s | 2016-10-06 15:55:55 |
%Y-%m-%d %H:%M | 2016-10-06 15:55 |
%Y-%m-%d | 2014-11-08 |
The dynamic scalar data type is special in that it can take on any value of other scalar data types from the list below, as well as arrays and property bags. Specifically, a dynamic value can be:
A literal of type dynamic looks like this:
dynamic (Value
)
Value can be:
ListOfValues
]. For example, dynamic([3, 4, “bye”]) is a dynamic array of three elements, two long values and one string value.Name
=Value ...
}. For example, dynamic(\{"a":1, "b":\{"a":2\}\})
is a property bag with two slots, a, and b, with the second slot being another property bag.The int data type represents a signed, 64-bit wide, integer.
The special form int(null) represents the null value.
int has an alias long
The long data type represents a signed, 64-bit wide, integer.
Literals of the long data type can be specified in the following syntax:
long(Value
)
Where Value can take the following forms:
-
) sign followed by one or more digits. For example, long(-3) is the number minus three of type long.The real data type represents a 64-bit wide, double-precision, floating-point number.
The string data type represents a sequence of zero or more Unicode characters.
There are several ways to encode literals of the string data type in a query text:
"
): “This is a string literal. Single quote characters (’) don’t require escaping. Double quote characters (”) are escaped by a backslash (\)”'
): Another string literal. Single quote characters (’) require escaping by a backslash (\). Double quote characters (”) do not require escaping.In the two representations above, the backslash (\
) character indicates escaping. The backslash is used to escape the enclosing quote characters, tab characters (\t
), newline characters (\n
), and itself (\\
).
Raw string literals are also supported. In this form, the backslash character (\
) stands for itself, and does not denote an escape sequence.
""
): @"This is a raw string literal"
'
): @'This is a raw string literal'
Raw strings are particularly useful for regexes where you can use @"^[\d]+$"
instead of "^[\\d]+$"
.
The timespan (time)
data type represents a time interval.
Literals of type timespan have the syntax timespan(value), where a number of formats are supported for value, as indicated by the following table:
Value | length of time |
---|---|
2d | 2 days |
1.5h | 1.5 hour |
30m | 30 minutes |
10s | 10 seconds |
timespan(15s) | 15 seconds |
0.1s | 0.1 second |
timespan(2d) | 2 days |
APL provides a set of functions to convert values between different scalar data types. These conversion functions allow you to convert a value from one type to another.
Some of the commonly used conversion functions include:
tobool()
: Converts input to boolean representation.todatetime()
: Converts input to datetime scalar.todouble()
or toreal()
: Converts input to a value of type real.tostring()
: Converts input to a string representation.totimespan()
: Converts input to timespan scalar.tolong()
: Converts input to long (signed 64-bit) number representation.toint()
: Converts input to an integer value (signed 64-bit) number representation.For a complete list of conversion functions and their detailed descriptions and examples, refer to the Conversion functions documentation.