Date Field Functions
Date Field Functions
Orchestrate performs no automatic type conversion of date fields. Either an input data set
must match the operator interface or you must effect a type conversion by means of the
transform or modify operator.
%yyyy-%mm-%dd When you specify a date format string, prefix each component with the
percent symbol (%). Separate the string’s components with any character except the percent
sign (%).
For example, the format string %mm/%dd/%yyyy specifies that slashes separate the string’s
date components; the format %ddd-%yy specifies that the string stores the date as a value
from 1 to 366, derives the year from the current year cutoff of 1900, and separates the two
components with a dash (-).
Function Description
date date_from_days_since
(int32, “date�? | format_variable) Returns date by adding the given integer to the baseline
date. Converts an integer field into a date by adding the integer to the specified base date.
The date must be in the format yyyy-mm-dd and must be either double quoted or a variable.
(string, "date_format" | date_uformat | format_variable) Returns a date from the given string
formatted in the optional format specification. By default the string format is yyyy-mm-dd.
date date_from_ustring
string string_from_date
(date, "date_format" | date_uformat) Converts the date to a string representation using the
given format specification. By default the ustring format is yyyy-mm-dd.
ustring ustring_from_date
(date, "date_format" | date_uformat) Converts the date to a ustring representation using the
given format specification. By default the ustring format is yyyy-mm-dd.
int8 month_from_date(date) Returns the month from the given date. For example,
date next_weekday_from_date
(date, “day�? | format_variable) The value returned is the date of the specified day of the
week soonest after date (including the date). The day argument is optional. It is a string or
variable specifying a day of the week. You can specify day by either the first three characters
of the day name or the full day name. By default, the value is Sunday.
date previous_weekday_from_date
(date, "day" | format_variable) Returns the previous weekday date from date. The destination
contains the closest date for the specified day of the week earlier than the source date
(including the source date) The day argument is optional. It is a string or variable specifying a
day of the week. You can specify day using either the first three characters of the day name or
the full day name. By default, the value is Sunday.
int8 weekday_from_date
(date, "origin_day" | format_variable) Returns the day of the week from date. The optional
argument origin_day is a string or variable specifying the day considered to be day zero of the
week. You can specify the day using either the first three characters of the day name or the
full day name. If omitted, Sunday is day zero.
int16 year_day_from_date(date) Returns the day of the year (1-366) from date.
int16 year_from_date(date) Returns the year from date. For example, the date 07-
int8 year_week_from_date(date) Returns the week of the year from date. For
example,
– ceil: Round the source field toward positive infinity. This mode corresponds to the IEEE 754
Round Up mode. Examples: 1.4 -> 2, -1.6 -> -1 – floor: Round the source field toward
negative infinity. This mode corresponds to the IEEE 754 Round Down mode. Examples: 1.6
-> 1, -1.4 -> -2 – round_inf: Round or truncate the source field toward the nearest
representable value, breaking ties by rounding positive values toward positive infinity and
negative values toward negative infinity. This mode corresponds to the COBOL ROUNDED
mode. Examples: 1.4 -> 1, 1.5 -> 2, -1.4 -> -1, -1.5 -> -2
– trunc_zero (default): Discard any fractional digits to the right of the rightmost fractional
digit supported in the destination, regardless of sign. For example, if the destination is an
integer, all fractional digits are truncated. If the destination is another decimal with a smaller
scale, round or truncate to the scale size of the destination decimal. This mode corresponds to
the COBOL INTEGER-PART function. Examples: 1.6 -> 1, -1.6 -> -1
decimal decimal_from_decimal
decimal decimal_from_dfloat
(dfloat, "r_type" | format_variable) Returns dfloat in decimal representation. The rounding
type, r_type, may be ceil, floor, round_inf, or trunc_zero as described above this table. The
default is trunc_zero.
decimal decimal_from_string
decimal decimal_from_ustring
dfloat dfloat_from_decimal
int32 int32_from_decimal
(decimal, "r_type fix_zero") Returns int32 in decimal representation. The rounding type,
r_type, may be ceil, floor, round_inf, or trunc_zero as described above this table. The default
is trunc_zero.
int64 int64_from_decimal
(decimal, "r_type fix_zero") Returns int32 in decimal representation. The rounding type,
r_type, may be ceil, floor, round_inf, or trunc_zero as described above this table. The default
is trunc_zero.
uint64 uint64_from_decimal
(decimal, "r_type fix_zero") Returns uint64 in decimal representation. The rounding type,
r_type, may be ceil, floor, round_inf, or trunc_zero as described above this table. The default
is trunc_zero.
string string_from_decimal
(decimal, "fix_zero suppress zero") Returns string in decimal representation. fix_zero causes a
decimal field containing all zeros to be treated as a valid zero. suppress_zero argument
specifies that the returned ustring value will have no leading or trailing zeros. Examples:
000.100 -> 0.1; 001.000 -> 1; -001.100 -> -1.1
ustring ustring_from_decimal
string string_from_decimal
(decimal) Returns the mantissa (the digits right of the decimal point) from decimal.
time Uformat
The time uformat provides support for international components in time fields. It’s syntax is:
string%macroString%macroString%macroString where %macro is a time formatting macro
such as %hh for a two-digit hour. See “time Format�? below for a description of the date
format macros. Only the String components of time uformat can include multi-byte Unicode
characters.
timestamp Uformat
This format is a concatenation of the date uformat and time uformat which are described in
“date Uformat�? on page 21--33 and “time Uformat�? on page 21--38. The order of the
formats does not matter, but the two formats cannot be mixed.
time Format
The time components of a source string (hours, minutes, and seconds) must be zero padded
to the character length specified by the format string; Orchestrate zero pads the time
components of a destination string to the specified length. The components of the format
string are:
The default time format is as follows: %hh:%nn:%ss When you specify a time format string,
prefix each component with the percent symbol (%). Separate the string’s components with
any character except the percent sign (%).
given time.
dfloat midnight_seconds_from_time
time.
int8 minutes_from_time(time) Returns the number of minutes from time.
dfloat seconds_from_time(time) Returns the number of seconds from time.
dfloat seconds_since_from_timestamp
time time_from_ustring
string string_from_time
(date, time) Returns a timestamp from date and time. The date specifies the date portion
(yyyy-nn-dd) of the timestamp. The time argument specifies the time to be used when
building the timestamp. The time argument must be in the hh:nn:ss format.
timestamp timestamp_from_seconds_since
timestamp timestamp_from_string
timestamp timestamp_from_ustring
string string_from_timestamp
ustring ustring_from_timestamp
(timestamp, "timestamp_format" | format_variable) Returns a ustring from timestamp. The
formatting specification is optional. The default format is yyyy-mm-dd hh:mm:ss.
field’s most negative possible value. This type of representation is called an inband null. In-
band null representation can be disadvantageous because you must reserve a field value for
nulls and this value cannot be treated as valid data elsewhere.
The null-handling functions can change a null representation from an out-of-band null to an in-
band null and from an in-band null to an out-of-band null.
destination_field handle_null
destination_field make_null
a-field = set_null();
int8 is_dfloat_inband_null
int8 is_int16_inband_null
int8 is_int32_inband_null
int8 is_int64_inband_null
int8 is_sfloat_inband_null
int8 is_string_inband_null
int8 u_is_string_inband_null
Mathematical Functions
int32 abs(int32) Returns the absolute value of int32.
dfloat acos(dfloat) Returns the principal value of the arc cosine of dfloat.
dfloat asin(dfloat) Returns the principal value of the arc sine of dfloat.
dfloat atan(dfloat) Returns the principal value of the arc tangent of dfloat.
dfloat atan2(dfloat, dfloat) Returns the principal value of the arc tangent of y/x (where
y is the first argument).
int ceil(decimal) Returns the smallest integer value greater than or equal to
decimal.
dfloat cos(dfloat) Returns the cosine of the given angle (dfloat) expressed in
radians.
(dfloat1, dfloat2) Returns the value of the quotient after dfloat1 is divided bydfloat2.
srand(uint32) Sets a new seed (uint32) for the frand() or srand() random number
generator.
srandom(uint32) Sets a random seed for the random() number generator. See the
UNIX man page for srandom for more details.
dfloat tan(dfloat) Returns the tangent of the given angle (dfloat) expressed in
radians.
Compared with rand, random is slower but more random. See the UNIX man page for random
for more details.
You can construct a string lookup table to use when default conversions do not yield
satisfactory results. A string lookup table is a table of two columns and as many rows as are
required to perform a conversion to or from a string as shown below. Each row of the lookup
table specifies an association between a 16-bit integer or unsigned 32-bit integer value and a
string or ustring. Orchestrate scans the Numeric Value or the String or Ustring column until it
encounters the value or string to be translated. The output is the corresponding entry in the
row. The numeric value to be converted may be of the int16 or the uint32 data type.
Orchestrate converts strings to values of the int16 or uint32 data type using the same table. If
the input contains a numeric value or string that is not listed in the table, Orchestrate
operates as follows:
A table definition defines the rows of a string or ustring lookup table and has the following
form: {propertyList} ('string' | 'ustring' = value; 'string' | 'ustring'= value; ... ) where:
propertyList is one or more of the following options; the entire list is enclosed in
braces and properties are separated by commas if there are more than one:
case_sensitive: perform a case-sensitive search for matching strings; the default is
case-insensitive.
default_value = defVal: the default numeric value returned for a string that does not
match any of the strings in the table.
default_string = defString: the default string returned for numeric values that do not
match any numeric value in the table.
A String Lookup Table Numeric Value String or Ustring numVal1 string1 | ustring1 numVal2
string2 | ustring1 ... ... numVal3 stringn | ustringn
characters.
characters.
int8 is_valid
int16 lookup_int16_from_string
string lookup_string_from_int16
string lookup_string_from_uint32
string string_from_date
string string_from_decimal
string string_from_time
string string_from_timestamp
string soundex
(input_string, length, censusOption) Returns a string which represents the phonetic code for
the string input word. Input words that produce the same code are considered phonetically
equivalent. The empty string is returned if the input string is empty. length is an int8 and can
be any value between 4 and 10. The default is 4. censusOption can be 0, 1, or 2 where 0 (the
default) is enhanced soundex and not a census code; 1 are the normal census codes used in
all censuses from 1920 on; and 2 are special census codes used intermittently in 1880, 1900,
and 1910.
string compact_whitespace
(string) Returns a string after reducing all consecutive white space in string to a single space.
string pad_string
(string, pad_string, pad_length) Returns the string with the pad_string appended to the
bounded length string for pad_length number of characters. pad_length is an int16. When the
given string is a variable-length string, it defaults to a bounded-length of 1024 characters. If
the given string is a fixed-length string, this function has no effect.
string strip_whitespace(string)
string trim_leading_trailing
(string) Returns string after removing all leading and trailing white space.
string trim_leading(string) Returns a string after removing all leading white space.
string trim_trailing(string) Returns a string after removing all trailing white space.
int32 string_order_compare
(string1, string2, justification) Returns a numeric value specifying the result of the
comparison. The numeric values are: -1: string1 is less than string2 0: string1 is equal to
string2 1: string1 is greater than string2 The string justification argument is either 'L' or 'R'. It
defaults to 'L' if not specified. 'L' means a standard character comparison, left to right. 'R'
means that any numeric substrings within the strings starting at the same position are
compared as numbers. For example an 'R' comparison of “AB100�? and “AB99�? indicates
that AB100 is great than AB99, since 100 is greater than 99. The comparisons are case
sensitive.
string replace_substring
(expression1, expression2, string) Returns a string value that contains the given string, with
any characters in expression1 replaced by their corresponding characters in expression2. For
example: replace_substring (“ABC:, “abZ�?, “AGDCBDA�?) returns “aGDZbDa�?, where any
“A�? gets replaced by “a�?, any “B�? gets replaced by “b�? and any “C�? gets replaced by
“Z�?. If expression2 is longer than expression1, the extra characters are ignored. If
expression1 is longer than expression2, the extra characters in expression1 are deleted from
the given string (the corresponding characters are removed.) For example:
replace_substring("ABC", "ab", "AGDCBDA") returns "aGDbDa".
int32 count_substring
int32 dcount_substring
(string, delimiter) Returns the number of fields in string delimited by delimiter, where
delimiter is a string. For example, dcount_substring(“abcFdefFghi�?, “F�?) returns 3. If
delimiter is an empty string, the number of characters in the string + 1 is returned. If
delimiter is not empty, but does not exist in the given string, 1 is returned.
string double_quote_string
string substring_by_delimiter
(string, delimiter, occurrence, numsubstr) The string and delimiter argumets are string values,
and the occurrence and numsubstr arguments are int32 values. This function returns
numsubstr substrings from string, delimited by delimiter and starting at substring number
occurence. An example is: substring_by_delimiter (“abcFdefFghiFjkl�?, “F�?, 2, 2) The string
“defFghi�? is returned. If occurence is < 1, then 1 is assumed. If occurence does not point to
an existing field, the empty string is returned. If numsubstr is not specified or is less than 1, it
defaults to 1.
int32 index_of_substring
(string, substring, occurrence) Returns the starting position of the nth occurrence of substring
in string. The occurrence argument is an integer indicating the nth occurrence. If there is no
nth occurrence or string doesn’t contain any substring, -1 is returned. If substring is an empty
string, -2 is returned.
string left_substring
(string, length) Returns the first length characters of string. If length is 0, it returns the empty
string. If length is greater than the length of the string, the entire string is returned.
string right_substring
(string, length) Returns the last length characters of string. If length is 0, it returns the empty
string. If length is greater than the length of string, the entire string is returned.
string string_of_substring
(string, count) Returns a string containing count occurrences of string. The empty string is
returned for a count of 0 or less.
string trimc_string
(string [,character [,option]]) If only string is specified, all leading and trailing spaces and tabs
are removed, and all multiple occurrences of spaces and tabs are reduced to a single space or
tab. If string and character are specified, option defaults to 'R' The available option values are:
'A' remove all occurrences of character 'B' remove both leading and trailing occurrences of
character. 'D' remove leading, trailing, and redundant whitespace characters. 'E' remove
trailing white-space characters 'F' remove leading white-space characters 'L' remove all
leading occurrences of character 'R' remove all leading, trailing, and redundant occurrences of
character 'T' remove all trailing occurrences of character
string system_time_date() Returns the current system time in this 24-hour format:
hh:mm:ss dd:mmm:yyyy
int32 offset_of_substring
(string, substring, position) Searches for the substring in the string beginning at character
number position, where position is an uint32. Returns the starting position of the substring.
int8 string_case_compare
int8 string_compare
(string, string) Compares two strings and returns the index (0 or 1) of the greater string.
int8 string_num_case_compare
string string_num_concatenate
(string, string, uint16) Returns a string after appending uint16 characters from the second
string onto the first string.
int8 string_num_compare
(string, string, uint16) Compares first uint16 characters of two given strings and returns the
index (0 or 1) of the greater string.
string string_num_copy
(string, uint16) Returns the first uint16 characters from the given string int32
string_length(string) Returns the length of the string.
string substring
ustring ustring_from_date
ustring ustring_from_decimal
ustring ustring_from_timestamp
(timestamp, "timestamp_format" | format_variable) Returns a ustring from timestamp. The
format specification is optional. The default format is yyyy-mm-dd hh:mm:ss.
int16 lookup_int16_from_ustring
ustring lookup_ustring_from_int16
ustring u_upper_case(ustring)
Returns the ustring after reducing all consecutive white space in ustring to a single space.
ustring u_pad_string
(ustring, pad_ustring, pad_length) Returns the ustring with pad_ustring appended to the
bounded length string for pad_length number of characters. pad_length is an int16. When the
given ustring is a variable-length string, it defaults to a bounded-length of 1024 characters. If
the given ustring is a fixed-length string, this function has no effect.
ustring u_strip_whitespace
(ustring) Returns ustring after stripping all white space in the string.
ustring u_trim_leading_trailing
(ustring) Returns ustring after removing all leading and trailing white space.
ustring u_trim_leading(ustring) Returns ustring after removing all leading white space.
ustring u_trim_trailing
int32 u_string_order_compare
(ustring1, ustring2, justification) Returns a numeric value specifying the result of the
comparison. The numeric values are: -1: ustring1 is less than ustring2 0: ustring1 is equal to
ustring2 1: ustring1 is greater than ustring2 The string justification argument is either 'L' or
'R'. It defaults to 'L' if not specified. 'L' means a standard character comparison, left to right.
'R' means that any numeric substrings within the strings starting at the same position are
compared as numbers. For example an 'R' comparison of “AB100�? and “AB99�? indicates
that AB100 is great than AB99, since 100 is greater than 99. The comparisons are case
sensitive.
ustring u_replace_substring
(expression1, expression2, ustring) Returns a ustring value that contains the given ustring,
with any characters in expression1 replaced by their corresponding characters in expression2.
For example: u_replace_substring (“ABC", “abZ�?, “AGDCBDA�?) returns “aGDZbDa�?,
where any “A�? gets replaced by “a�?, any “B�? gets replaced by “b�? and any “C�? gets
replaced by “Z�?. If expression2 is longer than expression1, the extra characters are ignored.
If expression1 is longer than expression2, the extra characters in expression1 are deleted
from the given string (the corresponding characters are removed.) For example:
u_replace_substring("ABC", "ab", "AGDCBDA") returns "aGDbDa".
int32 u_count_substring
(ustring, sub_ustring) Returns the number of times that sub_ustring occurs in ustring. If
sub_ustring is an empty string, the number of characters in ustring is returned.
int32 u_dcount_substring
(ustring, delimiter) Returns the number of fields in ustring delimited by delimiter, where
delimiter is a string. For example, dcount_substring(“abcFdefFghi�?, “F�?) returns 3. If
delimiter is an empty string, the number of characters in the string + 1 is returned. If
delimiter is not empty, but does not exist in the given string, 1 is returned.
ustring u_double_quote_string
ustring u_substring_by_delimiter
(ustring, delimiter, occurrence, numsubstr) The delimiter argument is a ustring value, and the
occurrence and numsubstr arguments are int32 values. This function returns numsubstr
substrings from ustring, delimited by delimiter and starting at substring number occurence. An
example is: u_substring_by_delimiter (“abcFdefFghiFjkl�?, “F�?, 2, 2) The string “defFghi�?
is returned. If occurence is < 1, then 1 is assumed. If occurence does not point to an existing
field, the empty string is returned. If numsubstr is not specified or is less than 1, it defaults to
1.
int32 u_index_of_substring
(ustring, sub_ustring, occurrence) Returns the starting position of the nth occurrence of
sub_ustring in ustring. The occurrence argument is an integer indicating the nth occurrence. If
there is no nth occurrence, 0 is returned; if sub_ustring is an empty string, -2 is returned; and
if ustring doesn’t contain any sub_ustring, -1 is returned.
ustring u_left_substring
(ustring, length) Returns the first length characters of ustring. If length is 0, it returns the
empty string. If length is greater than the length of the ustring, the entire ustring is returned.
ustring u_right_substring
(ustring, length) Returns the last length characters of ustring. If length is 0, it returns the
empty string. If length is greater than the length of ustring, the entire ustring is returned.
ustring u_string_of_space(count)
Returns a ustring containing count spaces. The empty string is returned for a count of 0 or
less.
ustring u_single_quote_string
ustring u_string_of_substring
(ustring, count) Returns a ustring containing count occurrences of ustring. The empty string is
returned for a count of 0 or less
ustring u_trimc_string
(ustring [,character [,option]]) If only ustring is specified, all leading and trailing spaces and
tabs are removed, and all multiple occurrences of spaces and tabs are reduced to a single
space or tab. If ustring and character are specified, option defaults to 'R' The available option
values are: 'A' remove all occurrences of character 'B' remove both leading and trailing
occurrences of character. 'D' remove leading, trailing, and redundant whitespace characters.
'E' remove trailing white-space characters 'F' remove leading white-space characters 'L'
remove all leading occurrences of character 'R' remove all leading, trailing, and redundant
occurrences of character 'T' remove all trailing occurrences of character
hh:mm:ss dd:mmm:yyyy
int32 u_offset_of_substring
(ustring, sub_ustring, position) Searches for the sub_ustring in the ustring beginning at
character number position, where position is an uint32. Returns the starting position of the
substring.
int8 u_string_case_compare
ustring u_string_num_concatenate
(ustring, ustring, uint16) Returns a ustring after appending uint16 characters from the second
ustring onto the first ustring.
int8 u_string_num_compare
(utring, ustring, uint16) Compares first uint16 characters of two given ustrings and returns the
index (0 or 1) of the greater ustring.
ustring u_string_num_copy
(ustring, uint16) Returns the first uint16 characters from the given ustring. int32
u_string_length(ustring) Returns the length of the ustring.
ustring u_substring
"&"
When this function is given an empty string, it returns 0; and when it is given a multi-
character string, it uses the first character in the string. An example use is:
u_num_from_char("&") which returns 38
binary representation.
field.
(uint64, list_of_bits, bit_state) Turns the uint64 bits that are listed by number in the string
list_of_bits on or off, depending on whether the value of the bit_state integer is 1 or 0.
bit_state is an optional argument, and has a default value of 1 which turns the list of bits on.
An example use is: set_bit(0, "1,3,5,7") which returns 85.
uint64 u_set_bit