Dmfunctions PDF
Dmfunctions PDF
DN3501991.0511
Cactus, EDA, EDA/SQL, FIDEL, FOCUS, Information Builders, the Information Builders logo, iWay, iWay Software,
Parlay, PC/FOCUS, RStat, TableTalk, Web390, and WebFOCUS are registered trademarks, and DataMigrator and
Magnify are trademarks of Information Builders, Inc.
Adobe, the Adobe logo, Acrobat, Adobe Reader, Flash, Adobe Flash Builder, Flex, and PostScript are either registered
trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries.
Due to the nature of this material, this document refers to numerous hardware and software products by their
trademarks. In most, if not all cases, these designations are claimed as trademarks or registered trademarks by their
respective companies. It is not this publisher’s intent to use any of these names generically. The reader is therefore
cautioned to investigate all claimed trademark rights before using any of these names other than to refer to the
product described.
Copyright © 2011, by Information Builders, Inc. and iWay Software. All rights reserved. Patent Pending. This manual,
or parts thereof, may not be reproduced in any form without the written permission of Information Builders, Inc.
iWay
Contents
Preface..............................................................................................................11
Documentation Conventions............................................................................................12
Related Publications........................................................................................................13
Customer Support...........................................................................................................13
Information You Should Have...........................................................................................14
User Feedback................................................................................................................15
iWay Software Training and Professional Services..............................................................15
1. Functions Overview......................................................................................17
Function Arguments.........................................................................................................18
Function Categories.........................................................................................................18
Character Chart for ASCII and EBCDIC..............................................................................19
2. Character Functions.......................................................................................27
ARGLEN: Measuring the Length of a String........................................................................28
ASIS: Distinguishing Between Space and Zero...................................................................29
BITSON: Determining If a Bit Is On or Off...........................................................................30
BITVAL: Evaluating a Bit String as an Integer.....................................................................31
BYTVAL: Translating a Character to Decimal......................................................................32
CHKFMT: Checking the Format of a String.........................................................................33
CTRAN: Translating One Character to Another....................................................................34
CTRFLD: Centering a Character String...............................................................................36
EDIT: Extracting or Adding Characters...............................................................................37
GETTOK: Extracting a Substring (Token)............................................................................38
LCWORD: Converting a String to Mixed-Case.....................................................................40
LCWORD2: Converting a String to Mixed-Case...................................................................41
LCWORD3: Converting a String to Mixed-Case...................................................................42
LJUST: Left-Justifying a String...........................................................................................43
LOCASE: Converting Text to Lowercase.............................................................................43
OVRLAY: Overlaying a Character String..............................................................................44
Functions Reference 3
Contents
4 iWay Software
Contents
6. Date Functions...............................................................................................93
Overview of Date Functions..............................................................................................94
Using Standard Date Functions........................................................................................94
Specifying Work Days...............................................................................................95
Enabling Leading Zeros For Date and Time Functions in Dialogue Manager..................98
DATEADD: Adding or Subtracting a Date Unit to or From a Date..........................................99
DATECVT: Converting the Format of a Date......................................................................101
DATEDIF: Finding the Difference Between Two Dates........................................................103
DATEMOV: Moving a Date to a Significant Point...............................................................105
DATETRAN: Formatting Dates in International Formats.....................................................107
FIYR: Obtaining the Financial Year..................................................................................121
FIQTR: Obtaining the Financial Quarter............................................................................123
FIYYQ: Converting a Calendar Date to a Financial Date.....................................................125
TODAY: Returning the Current Date.................................................................................127
Using Legacy Date Functions.........................................................................................127
Using Old Versions of Legacy Date Functions...........................................................128
AYM: Adding or Subtracting Months................................................................................129
AYMD: Adding or Subtracting Days.................................................................................130
CHGDAT: Changing How a Date String Displays...............................................................131
DA Functions: Converting a Legacy Date to an Integer......................................................133
DMY, MDY, YMD: Calculating the Difference Between Two Dates......................................134
DOWK and DOWKL: Finding the Day of the Week.............................................................135
DT Functions: Converting an Integer to a Date.................................................................136
GREGDT: Converting From Julian to Gregorian Format......................................................137
JULDAT: Converting From Gregorian to Julian Format........................................................138
YM: Calculating Elapsed Months....................................................................................139
7. Date-Time Functions....................................................................................141
Using Date-Time Functions.............................................................................................142
Date-Time Parameters...........................................................................................143
Supplying Arguments for Date-Time Functions..........................................................146
HADD: Incrementing a Date-Time Value...........................................................................147
HCNVRT: Converting a Date-Time Value to Alphanumeric Format.......................................148
Functions Reference 5
Contents
9. Numeric Functions.......................................................................................177
ABS: Calculating Absolute Value.....................................................................................178
CHKPCK: Validating a Packed Field.................................................................................178
DMOD, FMOD, and IMOD: Calculating the Remainder From a Division...............................180
EXP: Raising e to the Nth Power.....................................................................................181
EXPN: Evaluating a Number in Scientific Notation............................................................182
INT: Finding the Greatest Integer....................................................................................183
6 iWay Software
Contents
Functions Reference 7
Contents
8 iWay Software
Contents
Reader Comments...........................................................................................255
Functions Reference 9
Contents
10 iWay Software
iWay
Preface
This documentation describes how to use DataMigrator-supplied functions to perform complex
calculations and manipulate data in your procedures.
Chapter/Appendix Contents
5 Data Source and Decoding Describes data source and decoding functions that
Functions search for data source records, retrieve data source
records or values, and assign values based on the
value of an input field.
Functions Reference 11
Documentation Conventions
Chapter/Appendix Contents
12 SQL Date and Time Describes SQL date and time functions which
Functions manipulate date and time values.
13 SQL Data Type Conversion Describes SQL format conversion functions which
Functions convert fields from one format to another.
Documentation Conventions
The following table lists and describes the conventions that apply in this manual.
Convention Description
THIS TYPEFACE or Denotes syntax that you must enter exactly as shown.
this typeface
this typeface Highlights a file name or command. It may also indicate a button,
menu item, or dialog box option you can click or select.
12 iWay Software
Preface
Convention Description
{ } Indicates two or three choices; type one of them, not the braces.
... Indicates that you can enter a parameter multiple times. Type only
the parameter, not the ellipsis points (...).
Related Publications
To view a current listing of our publications and to place an order, visit our Technical
Documentation Library, http://documentation.informationbuilders.com. You can also contact
the Publications Order Department at (800) 969-4636.
Customer Support
Do you have questions about this product?
Join the Focal Point community. Focal Point is our online developer center and more than a
message board. It is an interactive network of more than 3,000 developers from almost
every profession and industry, collaborating on solutions and sharing tips and techniques,
http://forums.informationbuilders.com/eve/forums.
You can also access support services electronically, 24 hours a day, with InfoResponse
Online. InfoResponse Online is accessible through our World Wide Web site,
http://www.informationbuilders.com. It connects you to the tracking system and known-
problem database at the Information Builders support center. Registered users can open,
update, and view the status of cases in the tracking system and read descriptions of reported
software issues. New users can register immediately for this service. The technical support
section of www.informationbuilders.com also provides usage techniques, diagnostic tips,
and answers to frequently asked questions.
Functions Reference 13
Information You Should Have
Call Information Builders Customer Support Service (CSS) at (800) 736-6130 or (212) 736-
6130. Customer Support Consultants are available Monday through Friday between 8:00
a.m. and 8:00 p.m. EST to address all your questions. Information Builders consultants can
also give you general guidance regarding product capabilities and documentation. Please
be ready to provide your six-digit site code number (xxxx.xx) when you call.
To learn about the full range of available support services, ask your Information Builders
representative about InfoResponse Online, or call (800) 969-INFO.
14 iWay Software
Preface
Have you tried to reproduce your problem in the simplest form possible? For example, if
you are having problems joining two data sources, have you tried executing a query
containing just the code to access the data source?
Do you have a trace file?
How is the problem affecting your business? Is it halting development or production? Do
you just have questions about functionality or documentation?
User Feedback
In an effort to produce effective documentation, the Documentation Services staff welcomes
your opinions regarding this manual. Please use the Reader Comments form at the end of
this manual to communicate suggestions for improving this publication or to alert us to
corrections. You can also use the Documentation Feedback form on our Web site,
http://documentation.informationbuilders.com/feedback.asp.
Thank you, in advance, for your comments.
Functions Reference 15
iWay Software Training and Professional Services
16 iWay Software
iWay
1 Functions Overview
Functions Reference 17
Function Arguments
Function Arguments
All function arguments except the last one are input arguments. The formats for these
arguments are described with each function. Unless specified, every input argument can be
provided as one of the following:
A literal (that is, a number for numeric formats or a character string enclosed in single
quotation marks for alphanumeric formats).
A field of the correct format.
A variable assigned by a Dialogue Manager command.
An expression result evaluated in the correct format.
The output argument is the last function argument. With few exceptions, it is a required
argument whose only goal is to provide a format for the output of a function. It is not a field
to put the result in. The format can be provided as either:
A character string enclosed in single quotation marks.
A field name whose format is to be used.
This field is the one to which the result of the expression evaluation is assigned. If the
output_format is alphanumeric, its size should be large enough to fit the function output
and avoid truncation; excessive size causes the output to be padded with blanks.
Function Categories
Functions are grouped into the following areas:
Character Functions on page 27
Variable Length Character Functions on page 63
Character Functions for DBCS Code Pages on page 73
Data Source and Decoding Functions on page 85
Date Functions on page 93
Using Standard Date Functions on page 94
Using Legacy Date Functions on page 127
Date-Time Functions on page 141
Format Conversion Functions on page 163
Numeric Functions on page 177
18 iWay Software
1. Functions Overview
33 ! exclamation point
35 # number sign
36 $ dollar sign
37 % percent
38 & ampersand
39 ' apostrophe
40 ( left parenthesis
41 ) right parenthesis
42 * asterisk
43 + plus sign
44 , comma
45 - hyphen
46 . period
47 / slash
48 0 0
49 1 1
50 2 2
51 3 3
Functions Reference 19
Character Chart for ASCII and EBCDIC
52 4 4
53 5 5
54 6 6
55 7 7
56 8 8
57 9 9
58 : colon
59 ; semicolon
61 = equal sign
63 ? question mark
64 @ at sign
65 A A
66 B B
67 C C
68 D D
69 E E
70 F F
71 G G
72 H H
73 I I
20 iWay Software
1. Functions Overview
74 J J ¢ cent sign
75 K K . period
77 M M ( left parenthesis
78 N N + plus sign
79 O O | logical or
80 P P & ampersand
81 Q Q
82 R R
83 S S
84 T T
85 U U
86 V V
87 W W
88 X X
89 Y Y
90 Z Z ! exclamation point
94 ^ caret ; semicolon
Functions Reference 21
Character Chart for ASCII and EBCDIC
97 a a / slash
98 b b
99 c c
100 d d
101 e e
102 f f
103 g g
104 h h
105 i i
106 j j
107 k k , comma
108 l l % percent
109 m m _ underscore
112 p p
113 q q
114 r r
115 s s
116 t t
117 u u
22 iWay Software
1. Functions Overview
118 v v
119 w w
120 x x
121 y y
122 z z : colon
129 a a
130 b b
131 c c
132 d d
133 e e
134 f f
135 g g
136 h h
137 i i
145 j j
146 k k
147 l l
Functions Reference 23
Character Chart for ASCII and EBCDIC
148 m m
149 n n
150 o o
151 p p
152 q q
153 r r
162 s s
163 t t
164 u u
165 v v
166 w w
167 x x
168 y y
169 z z
193 A A
194 B B
195 C C
196 D D
197 E E
198 F F
199 G G
24 iWay Software
1. Functions Overview
200 H H
201 I I
209 J J
210 K K
211 L L
212 M M
213 N N
214 O O
215 P P
216 Q Q
217 R R
226 S S
227 T T
228 U U
229 V V
230 W W
231 X X
232 Y Y
233 Z Z
240 0 0
241 1 1
242 2 2
Functions Reference 25
Character Chart for ASCII and EBCDIC
243 3 3
244 4 4
245 5 5
246 6 6
247 7 7
248 8 8
249 9 9
26 iWay Software
iWay
2 Character Functions
Topics:
LOCASE: Converting Text to Lowercase
ARGLEN: Measuring the Length of a String OVRLAY: Overlaying a Character String
ASIS: Distinguishing Between Space and Zero PARAG: Dividing Text Into Smaller Lines
BITSON: Determining If a Bit Is On or Off PATTERN: Generating a Pattern From a String
BITVAL: Evaluating a Bit String as an Integer POSIT: Finding the Beginning of a Substring
BYTVAL: Translating a Character to Decimal REVERSE: Reversing the Characters in a String
CHKFMT: Checking the Format of a String RJUST: Right-Justifying a Character String
CTRAN: Translating One Character to Another SOUNDEX: Comparing Character Strings
Phonetically
CTRFLD: Centering a Character String
SPELLNM: Spelling Out a Dollar Amount
EDIT: Extracting or Adding Characters
SQUEEZ: Reducing Multiple Spaces to a Single
GETTOK: Extracting a Substring (Token)
Space
LCWORD: Converting a String to Mixed-Case
STRIP: Removing a Character From a String
LCWORD2: Converting a String to Mixed-Case
STRREP: Replacing Character Strings
LCWORD3: Converting a String to Mixed-Case
SUBSTR: Extracting a Substring
LJUST: Left-Justifying a String
TRIM: Removing Leading and Trailing
Occurrences
UPCASE: Converting Text to Uppercase
Functions Reference 27
ARGLEN: Measuring the Length of a String
The ARGLEN function measures the length of a character string within a field, excluding
trailing spaces. The field format in a Master File specifies the length of a field, including
trailing spaces.
In Dialogue Manager, you can measure the length of a supplied character string using the
.LENGTH suffix.
28 iWay Software
2. Character Functions
The ASIS function distinguishes between a space and a zero in Dialogue Manager. It
differentiates between a numeric string, a constant or variable defined as a numeric string
(number within single quotation marks), and a field defined simply as numeric. ASIS forces
a variable to be evaluated as it is entered rather than be converted to a number. It is used
in Dialogue Manager equality expressions only.
Functions Reference 29
BITSON: Determining If a Bit Is On or Off
The next request uses ASIS to distinguish between the two variables.
-SET &VAR1 = ' ';
-SET &VAR2 = 0;
-IF &VAR2 EQ ASIS(&VAR1) GOTO ONE;
-TYPE VAR1 &VAR1 EQ VAR2 &VAR2 NOT TRUE
-QUIT
-ONE
-TYPE VAR1 &VAR1 EQ VAR2 &VAR2 TRUE
The output is:
VAR1 EQ VAR2 0 NOT TRUE
The BITSON function evaluates an individual bit within a character string to determine whether
it is on or off. If the bit is on, BITSON returns a value of 1. If the bit is off, it returns a value
of 0. This function is useful in interpreting multi-punch data, where each punch conveys an
item of information.
30 iWay Software
2. Character Functions
output
Integer
The BITVAL function evaluates a string of bits within a character string. The bit string can
be any group of bits within the character string and can cross byte and word boundaries.
The function evaluates the subset of bits in the string as an integer value.
Functions Reference 31
BYTVAL: Translating a Character to Decimal
output
Integer
The BYTVAL function translates a character to the ASCII, EBCDIC, or Unicode decimal value
that represents it, depending on the operating system.
32 iWay Software
2. Character Functions
The CHKFMT function checks a character string for incorrect characters or character types.
It compares each character string to a second string, called a mask, by comparing each
character in the first string to the corresponding character in the mask. If all characters in
the character string match the characters or character types in the mask, CHKFMT returns
the value 0. Otherwise, CHKFMT returns a value equal to the position of the first character
in the character string not matching the mask.
If the mask is shorter than the character string, the function checks only the portion of the
character string corresponding to the mask. For example, if you are using a four-character
mask to test a nine-character string, only the first four characters in the string are checked;
the rest are returned as a no match with CHKFMT giving the first non-matching position as
the result.
Functions Reference 33
CTRAN: Translating One Character to Another
Is the mask, which contains the comparison characters enclosed in single quotation
marks.
Some characters in the mask are generic and represent character types. If a character
in the string is compared to one of these characters and is the same type, it matches.
Generic characters are:
A is any letter between A and Z (uppercase or lowercase).
$ is any character.
Any other character in the mask represents only that character. For example, if the third
character in the mask is B, the third character in the string must be B to match.
output
Integer
The CTRAN function translates a character within a character string to another character
based on its decimal value. This function is especially useful for changing replacement
characters to unavailable characters, or to characters that are difficult to input or unavailable
on your keyboard. It can also be used for inputting characters that are difficult to enter when
responding to a Dialogue Manager -PROMPT command, such as a comma or apostrophe. It
eliminates the need to enclose entries in single quotation marks.
34 iWay Software
2. Character Functions
To use CTRAN, you must know the decimal equivalent of the characters in internal machine
representation. Note that the coding chart for conversion is platform dependent, hence your
platform and configuration option determines whether ASCII, EBCDIC, or Unicode coding is
used. Printable EBCDIC or ASCII characters and their decimal equivalents are listed in
Character Chart for ASCII and EBCDIC on page 19.
In Unicode configurations, this function uses values in the range:
0 to 255 for 1-byte characters.
256 to 65535 for 2-byte characters.
65536 to 16777215 for 3-byte characters.
16777216 to 4294967295 for 4-byte characters (primarily for EBCDIC).
Functions Reference 35
CTRFLD: Centering a Character String
The CTRFLD function centers a character string within a field. The number of leading spaces
is equal to or one less than the number of trailing spaces.
CTRFLD is useful for centering the contents of a field and its report column, or a heading
that consists only of an embedded field. HEADING CENTER centers each field value including
trailing spaces. To center the field value without the trailing spaces, first center the value
within the field using CTRFLD.
36 iWay Software
2. Character Functions
output
Alphanumeric
The EDIT function extracts characters from the source string and adds characters to the
output string, according to the mask. It can extract a substring from different parts of the
source string. It can also insert characters from the source string into an output string. For
example, it can extract the first two characters and the last two characters of a string to
form a single output string.
EDIT compares the characters in a mask to the characters in a source string. When it
encounters a nine (9) in the mask, EDIT copies the corresponding character from the source
field to the output string. When it encounters a dollar sign ($) in the mask, EDIT ignores the
corresponding character in the source string. When it encounters any other character in the
mask, EDIT copies that character to the corresponding position in the output string. This
process ends when the mask is exhausted.
Note:
EDIT does not require an output argument because the result is alphanumeric and its
size is determined from the mask value.
EDIT can also convert the format of a field. For information on converting a field with
EDIT, see EDIT: Converting the Format of a Field on page 165.
Functions Reference 37
GETTOK: Extracting a Substring (Token)
The GETTOK function divides a character string into substrings, called tokens. The data must
have a specific character, called a delimiter, that occurs in the string and separates the
string into tokens. GETTOK returns the token specified by the token_number argument.
GETTOK ignores leading and trailing blanks in the source character string.
For example, suppose you want to extract the fourth word from a sentence. In this case,
use the space character for a delimiter and the number 4 for token_number. GETTOK divides
the sentence into words using this delimiter, then extracts the fourth word. If the string is
not divided by the delimiter, use the PARAG function for this purpose. See PARAG: Dividing
Text Into Smaller Lines on page 46.
38 iWay Software
2. Character Functions
Functions Reference 39
LCWORD: Converting a String to Mixed-Case
The LCWORD function converts the letters in a character string to mixed-case. It converts
every alphanumeric character to lowercase except the first letter of each new word and the
first letter after a single or double quotation mark, which it convers to uppercase. For example,
O'CONNOR is converted to O'Connor and JACK'S to Jack'S.
LCWORD skips numeric and special characters in the source string and continues to convert
the following alphabetic characters. The result of LCWORD is a string in which the initial
uppercase characters of all words are followed by lowercase characters.
40 iWay Software
2. Character Functions
The LCWORD2 function converts the letters in a character string to mixed-case by converting
the first letter of each word to uppercase and converting every other letter to lowercase. In
addition, a double quotation mark or a space indicates that the next letter should be converted
to uppercase.
For example, "SMITH" would be changed to "Smith" and "JACK S" would be changed to
"Jack S".
Functions Reference 41
LCWORD3: Converting a String to Mixed-Case
The LCWORD3 function converts the letters in a character string to mixed-case by converting
the first letter of each word to uppercase and converting every other letter to lowercase. In
addition, a single quotation mark indicates that the next letter should be converted to
uppercase, as long as it is neither followed by a blank nor the last character in the input
string.
For example, 'SMITH' would be changed to 'Smith' and JACK'S would be changed to Jack's.
42 iWay Software
2. Character Functions
Functions Reference 43
OVRLAY: Overlaying a Character String
The OVRLAY function overlays a base character string with a substring. The function enables
you to edit part of an alphanumeric field without replacing the entire field.
44 iWay Software
2. Character Functions
Functions Reference 45
PARAG: Dividing Text Into Smaller Lines
The PARAG function divides a character string into substrings by marking them with a
delimiter. It scans a specific number of characters from the beginning of the string and
replaces the last space in the group scanned with the delimiter, thus creating a first substring,
also known as a token. It then scans the next group of characters in the line, starting from
the delimiter, and replaces its last space with a second delimiter, creating a second token.
It repeats this process until it reaches the end of the line.
Once each token is marked off by the delimiter, you can use the function GETTOK to place
the tokens into different fields (see GETTOK: Extracting a Substring (Token) on page 38). If
PARAG does not find any spaces in the group it scans, it replaces the first character after
the group with the delimiter. Therefore, make sure that any group of characters has at least
one space. The number of characters scanned is provided as the maximum token size.
For example, if you have a field called 'subtitle' which contains a large amount of text
consisting of words separated by spaces, you can cut the field into roughly equal substrings
by specifying a maximum token size to divide the field. If the field is 350 characters long,
divide it into three substrings by specifying a maximum token size of 120 characters. This
technique enables you to print lines of text in paragraph form.
Tip: If you divide the lines evenly, you may create more sub-lines than you intend. For example,
suppose you divide 120-character text lines into two lines of 60 characters maximum, but
one line is divided so that the first sub-line is 50 characters and the second is 55. This
leaves room for a third sub-line of 15 characters. To correct this, insert a space (using weak
concatenation) at the beginning of the extra sub-line, then append this sub-line (using strong
concatenation) to the end of the one before it. Note that the sub-line will be longer than 60
characters.
46 iWay Software
2. Character Functions
source_string
Alphanumeric
Is a string to divide into tokens.
delimiter
Alphanumeric
Is the delimiter enclosed in single quotation marks. Choose a character that does not
appear in the text.
max_token_size
Integer
Is the upper limit for the size of each token.
output
Alphanumeric
The PATTERN function examines a source string and produces a pattern that indicates the
sequence of numbers, uppercase letters, and lowercase letters in the source string. This
function is useful for examining data to make sure that it follows a standard pattern.
In the output pattern:
Any character from the input that represents a single-byte digit becomes the character
9.
Any character that represents an uppercase letter becomes A, and any character that
represents a lowercase letter becomes a. For European NLS mode (Western Europe,
Central Europe), A and a are extended to apply to accented alphabets.
Functions Reference 47
POSIT: Finding the Beginning of a Substring
The POSIT function finds the starting position of a substring within a source string. For
example, the starting position of the substring DUCT in the string PRODUCTION is 4. If the
substring is not in the parent string, the function returns the value 0.
48 iWay Software
2. Character Functions
Functions Reference 49
REVERSE: Reversing the Characters in a String
The RJUST function right-justifies a character string. All trailing blacks become leading blanks.
This is useful when you display alphanumeric fields containing numbers.
50 iWay Software
2. Character Functions
The SOUNDEX function analyzes a character string phonetically, without regard to spelling.
It converts character strings to four character codes. The first character must be the first
character in the string. The last three characters represent the next three significant sounds
in the source string.
Functions Reference 51
SPELLNM: Spelling Out a Dollar Amount
The SPELLNM function spells out an alphanumeric string or numeric value containing two
decimal places as dollars and cents. For example, the value 32.50 is THIRTY TWO DOLLARS
AND FIFTY CENTS.
52 iWay Software
2. Character Functions
If you know the maximum value of number, use the following table to determine the
value of outlength:
$10 37
$100 45
$1,000 59
$10,000 74
$100,000 82
$1,000,000 96
number
Alphanumeric or Numeric (9.2)
Is the number to be spelled out. This value must contain two decimal places.
output
Alphanumeric
Functions Reference 53
SQUEEZ: Reducing Multiple Spaces to a Single Space
The SQUEEZ function reduces multiple contiguous spaces within a character string to a
single space. The resulting character string has the same length as the original string but
is padded on the right with spaces.
54 iWay Software
2. Character Functions
The STRIP function removes all occurrences of a specific character from a string. The resulting
character string has the same length as the original string but is padded on the right with
spaces.
Functions Reference 55
STRREP: Replacing Character Strings
The STRREP replaces all instances of a specified string within a source string. It also supports
replacement by null strings.
56 iWay Software
2. Character Functions
outlength
Numeric
Is the number of characters in the resulting output string. Must be 1 or greater.
output
Alphanumeric
The SUBSTR function extracts a substring based on where it begins and its length in the
source string.
Functions Reference 57
SUBSTR: Extracting a Substring
start
Integer
Is the starting position of the substring in the source string. If start is less than one or
greater than length, the function returns spaces.
end
Integer
Is the ending position of the substring. If this argument is less than start or greater than
length, the function returns spaces.
sublength
Integer
Is the number of characters in the substring (normally end - start + 1). If sublength is
longer than end - start +1, the substring is padded with trailing spaces. If it is shorter,
the substring is truncated. This value should be the declared length of output. Only
sublength characters will be processed.
output
Alphanumeric
58 iWay Software
2. Character Functions
The TRIM function removes leading and/or trailing occurrences of a pattern within a character
string.
Functions Reference 59
UPCASE: Converting Text to Uppercase
output
Alphanumeric
The UPCASE function converts a character string to uppercase. It is useful for sorting on a
field that contains both mixed-case and uppercase values. Sorting on a mixed-case field
produces incorrect results because the sorting sequence in EBCDIC always places lowercase
letters before uppercase letters, while the ASCII sorting sequence always places uppercase
letters before lowercase. To obtain correct results, define a new field with all of the values
in uppercase, and sort on that.
60 iWay Software
2. Character Functions
Functions Reference 61
UPCASE: Converting Text to Uppercase
62 iWay Software
iWay
Functions Reference 63
Overview
Overview
For relational data sources, AnV keeps track of the actual length of a VARCHAR column. This
information is especially valuable when the value is used to populate a VARCHAR column
in a different RDBMS. It affects whether trailing blanks are retained in string concatenation
and, for Oracle, string comparisons (the other relational engines ignore trailing blanks in
string comparisons).
In a FOCUS or XFOCUS data source, AnV does not provide true variable length character
support. It is a fixed-length character field with an extra two leading bytes to contain the
actual length of the data stored in the field. This length is stored as a short integer value
occupying two bytes. Because of the two bytes of overhead and the additional processing
required to strip them, AnV format is not recommended for use with non-relational data
sources.
AnV fields can be used as arguments to all Information Builders-supplied functions that
expect alphanumeric arguments. An AnV input parameter is treated as an An parameter and
is padded with blanks to its declared size (n). If the last parameter specifies an AnV format,
the function result is converted to type AnV with actual length set equal to its size.
The functions described in this topic are designed to work specifically with the AnV data type
parameters.
LENV returns the actual length of an AnV field or the size of an An field.
64 iWay Software
3. Variable Length Character Functions
output
Integer
The LOCASV function converts alphabetic characters in the source string to lowercase and
is similar to LOCASE. LOCASV returns AnV output whose actual length is the lesser of the
actual length of the AnV source string and the value of the input parameter upper_limit.
Functions Reference 65
POSITV: Finding the Beginning of a Variable Length Substring
The POSITV function finds the starting position of a substring within a larger string. For
example, the starting position of the substring DUCT in the string PRODUCTION is 4. If the
substring is not in the parent string, the function returns the value 0. This is similar to POSIT;
however, the lengths of its AnV parameters are based on the actual lengths of those
parameters in comparison with two other parameters that specify their sizes.
66 iWay Software
3. Variable Length Character Functions
sub_limit
Integer
Is limit for the length of the substring.
output
Integer
The SUBSTV function extracts a substring from a string and is similar to SUBSTR. However,
the end position for the string is calculated from the starting position and the substring
length. Therefore, it has fewer parameters than SUBSTR. Also, the actual length of the output
field, if it is an AnV field, is determined based on the substring length.
Functions Reference 67
SUBSTV: Extracting a Variable Length Substring
source_string
Alphanumeric of type An or AnV
Is the character string that contains the substring you want to extract. If it is a field of
type AnV, its length is taken from the length bytes stored in the field. If upper_limit is
smaller than the actual length, the source string is truncated to the upper limit. The final
length value determined by this comparison is referred to as p_length (see the description
of the output parameter for related information).
start
Integer
Is the starting position of the substring in the source string. The starting position can
exceed the source string length, which results in spaces being returned.
sub_limit
Integer
Is the length, in characters, of the substring (normally end - start + 1). The end position
of the substring is end =start + sublength -1. Note that the ending position can exceed
the input string length depending on the provided values for start and sub_limit.
output
Alphanumeric of type An or AnV
If the format of output is AnV, the actual length, outlen, is computed as follows from the
values for end, start, and p_length (see the source_string parameter for related
information):
If end > p_length or end < start, then outlen = 0. Otherwise, outlen = end - start + 1.
68 iWay Software
3. Variable Length Character Functions
The TRIMV function removes leading and/or trailing occurrences of a pattern within a character
string. TRIMV is similar to TRIM. However, TRIMV allows the source string and the pattern
to be removed to have AnV format.
TRIMV is useful for converting an An field to an AnV field (with the length in bytes containing
the actual length of the data up to the last non-blank character).
Functions Reference 69
UPCASV: Creating a Variable Length Uppercase String
plength_limit
Integer
Is the limit for the length of the pattern.
output
Alphanumeric of type An or AnV
If the output format is AnV, the length is set to the number of characters left after
trimming.
70 iWay Software
3. Variable Length Character Functions
output
Alphanumeric of type An or AnV
If the output format is AnV, the length returned is equal to the smaller of the source
string length and upper_limit.
Functions Reference 71
UPCASV: Creating a Variable Length Uppercase String
72 iWay Software
iWay
Functions Reference 73
DCTRAN: Translating A Single-Byte or Double-Byte Character to Another
74 iWay Software
4. Character Functions for DBCS Code Pages
If your configuration uses a DBCS code page, you can use the DEDIT function to extract
characters from or add characters to a string.
DEDIT works by comparing the characters in a mask to the characters in a source field.
When it encounters a nine (9) in the mask, DEDIT copies the corresponding character from
the source field to the new field. When it encounters a dollar sign ($) in the mask, DEDIT
ignores the corresponding character in the source field. When it encounters any other
character in the mask, DEDIT copies that character to the corresponding position in the new
field.
Functions Reference 75
DSTRIP: Removing a Single-Byte or Double-Byte Character From a String
mask
Alphanumeric
Is the string of mask characters.
Each nine (9) in the mask causes the corresponding character from the source field to
be copied to the new field.
Each dollar sign ($) in the mask causes the corresponding character in the source field
to be ignored.
Any other character in the mask is copied to the new field.
output
Alphanumeric
The following example copies alternate characters from the source string to the new field,
starting with the second character in the source string, and then adds several new characters
at the end of the extracted string:
The DSTRIP function removes all occurrences of a specific single-byte or double-byte character
from a string. The resulting character string has the same length as the original string but
is padded on the right with spaces.
76 iWay Software
4. Character Functions for DBCS Code Pages
If your configuration uses a DBCS code page, you can use the DSUBSTR function to extract
a substring based on its length and position in the source string.
Functions Reference 77
DSUBSTR: Extracting a Substring
78 iWay Software
4. Character Functions for DBCS Code Pages
output
Alphanumeric
Functions Reference 79
JPTRANS: Converting Japanese Specific Characters
length
Integer
Is the number of characters in the source_string.
source_string
Alphanumeric
Is the string to convert.
output_format
Alphanumeric
Is the name of the field that contains the output, or the format enclosed in single
quotation marks.
80 iWay Software
4. Character Functions for DBCS Code Pages
Functions Reference 81
JPTRANS: Converting Japanese Specific Characters
In the following, codepoints 0x62 0x63 0x64 are converted to 0x81 0x82 0x83, respectively:
JPTRANS('930TO939', 20, CP930_Field, 'A20')
In the following, codepoints 0x59 0x62 0x63 are converted to 0x81 0x82 0x83, respectively:
JPTRANS('939TO930', 20, CP939_Field, 'A20')
82 iWay Software
4. Character Functions for DBCS Code Pages
Fullwidth Single Quote ' (U+FF07) -> Single Quote ' (U+0027)
Fullwidth Ideographic Comma (U+3001) -> Comma , (U+002C)
Fullwidth Comma , (U+FF0C) -> Comma , (U+002C)
Fullwidth Ideographic Full Stop ? (U+3002) -> Full Stop . (U+002E)
Fullwidth Full Stop . (U+FF0E) -> Full Stop . (U+002E)
Fullwidth Yen Sign ¥ (U+FFE5) -> Yen Sign ¥ (U+00A5)
Fullwidth Backslash \ (U+FF3C) -> Backslash \ (U+005C)
Fullwidth Left Corner Bracket (U+300C) -> Halfwidth Left Corner Bracket (U+FF62)
Fullwidth Right Corner Bracket (U+300D) -> Halfwidth Right Corner Bracket (U+FF63)
Fullwidth Middle Dot · (U+30FB) -> Halfwidth Katakana Middle Dot · (U+FF65)
HNZNKANA and ZNHNKANA focus on the conversion of Katakana
They convert not only letters but also punctuation symbols on the following list:
Fullwidth Ideographic Comma (U+3001) <-> Halfwidth Ideographic Comma (U+FF64)
Fullwidth Ideographic Full Stop (U+3002) <-> Halfwidth Ideographic Full Stop (U+FF61)
Fullwidth Left Corner Bracket (U+300C) <-> Halfwidth Left Corner Braket (U+FF62)
Fullwidth Right Corner Bracket (U+300D) <-> Halfwidth Right Corner Bracket (U+FF63)
Fullwidth Middle Dot · (U+30FB) <-> Halfwidth Katakana Middle Dot · (U+FF65)
Fullwidth Prolonged Sound (U+30FC) <-> Halfwidth Prolonged Sound (U+FF70)
JPTRANS can be nested for multiple conversions.
For example, text data may contain fullwidth numbers and fullwidth symbols. In some
situations, they should be cleaned up for ASCII numbers and symbols.
Functions Reference 83
JPTRANS: Converting Japanese Specific Characters
84 iWay Software
iWay
Functions Reference 85
DB_LOOKUP: Retrieving Data Source Values
The DB_LOOKUP function enables you to retrieve a value from one data source when running
a request against another data source, without joining or combining the two data sources.
DB_LOOKUP compares pairs of fields from the source and lookup data sources to locate
matching records and retrieve the value to return to the request. You can specify as many
pairs as needed to get to the lookup record that has the value you want to retrieve. If your
field list pairs do not lead to a unique lookup record, the first matching lookup record retrieved
is used.
DB_LOOKUP can be called in a DEFINE command, TABLE COMPUTE command, MODIFY
COMPUTE command, or DataMigrator flow.
There are no restrictions on the source file. The lookup file can be any non-FOCUS data
source that is supported as the cross referenced file in a cluster join. The lookup fields used
to find the matching record are subject to the rules regarding cross-referenced join fields for
the lookup data source. A fixed format sequential file can be the lookup file if it is sorted in
the same order as the source file.
86 iWay Software
5. Data Source and Decoding Functions
returnfld
Is the name of a column in the lookup file whose value is returned from the matching
lookup record. Only columns in the table or file can be used; columns created with DEFINE
cannot be used.
Functions Reference 87
DECODE: Decoding Values
The DECODE function assigns values based on the coded value of an input field. DECODE
is useful for giving a more meaningful value to a coded value in a field. For example, the
field GENDER may have the code F for female employees and M for male employees for
efficient storage (for example, one character instead of six for female). DECODE expands
(decodes) these values to ensure correct interpretation on a report.
You can use DECODE by supplying values directly in the function or by reading values from
a separate file.
88 iWay Software
5. Data Source and Decoding Functions
default
Alphanumeric or Numeric
Is the value returned as a result for non-matching codes. The format must be the same
as the format of result. If you omit a default value, DECODE assigns a blank or zero to
non-matching codes.
filename
Alphanumeric
Is the name of the file in which code/result pairs are stored. Every record in the file must
contain a pair.
You can use up to 40 lines to define the code and result pairs for any given DECODE function,
or 39 lines if you also use an ELSE phrase. Use either a comma or blank to separate the
code from the result, or one pair from another.
Note: DECODE has no output argument.
The FIND function determines if an incoming data value is in an indexed FOCUS data source
field. The function sets a temporary field to a non-zero value if the incoming value is in the
data source field, and to 0 if it is not. A value greater than zero confirms the presence of
the data value, not the number of instances in the data source field.
You can also use FIND in a VALIDATE command to determine if a transaction field value
exists in another FOCUS data source. If the field value is not in that data source, the function
returns a value of 0, causing the validation test to fail and the request to reject the
transaction.
Functions Reference 89
LAST: Retrieving the Preceding Value
You can use any number of FINDs in a COMPUTE or VALIDATE command. However, more
FINDs increase processing time and require more buffer space in memory.
Limit: FIND does not work on files with different DBA passwords.
The opposite of FIND is NOT FIND. The NOT FIND function sets a temporary field to 1 if the
incoming value is not in the data source and to 0 if the incoming value is in the data source.
90 iWay Software
5. Data Source and Decoding Functions
The LOOKUP function retrieves a data value from a cross-referenced FOCUS data source in
a MODIFY request. You can retrieve data from a data source cross-referenced statically in
a synonym or a data source joined dynamically to another by the JOIN command. LOOKUP
retrieves a value, but does not activate the field. LOOKUP is required because a MODIFY
request, unlike a TABLE request, cannot read cross-referenced data sources freely.
LOOKUP allows a request to use the retrieved data in a computation or message, but it does
not allow you to modify a cross-referenced data source.
LOOKUP can read a cross-referenced segment that is linked directly to a segment in the
host data source (the host segment). This means that the cross-referenced segment must
have a segment type of KU, KM, DKU, or DKM (but not KL or KLU) or must contain the cross-
referenced field specified by the JOIN command. Because LOOKUP retrieves a single cross-
referenced value, it is best used with unique cross-referenced segments.
Functions Reference 91
LOOKUP: Retrieving a Value From a Cross-referenced Data Source
The cross-referenced field. This field shares values with a field in the host segment called
the host field. These two fields link the host segment to the cross-referenced segment.
LOOKUP uses the cross-referenced field, which is indexed, to locate a specific segment
instance.
When using LOOKUP, the MODIFY request reads a transaction value for the host field. It
then searches the cross-referenced segment for an instance containing this value in the
cross-referenced field:
If there are no instances of the value, the function sets a return variable to 0. If you use
the field specified by LOOKUP in the request, the field assumes a value of blank if
alphanumeric and 0 if numeric.
If there are instances of the value, the function sets the return variable to 1 and retrieves
the value of the specified field from the first instance it finds. There can be more than
one if the cross-referenced segment type is KM or DKM, or if you specified the ALL
keyword in the JOIN command.
92 iWay Software
iWay
6 Date Functions
Date functions manipulate date values. There are two types of date functions:
Standard date functions for use with non-legacy dates.
Legacy date functions for use with legacy dates.
If a date is in an alphanumeric or numeric field that contains date display options (for example, I6YMD),
you must use the legacy date functions.
Topics:
Using Legacy Date Functions
Overview of Date Functions AYM: Adding or Subtracting Months
Using Standard Date Functions AYMD: Adding or Subtracting Days
DATEADD: Adding or Subtracting a Date Unit CHGDAT: Changing How a Date String Displays
to or From a Date
DA Functions: Converting a Legacy Date to an
DATECVT: Converting the Format of a Date Integer
DATEDIF: Finding the Difference Between Two DMY, MDY, YMD: Calculating the Difference
Dates Between Two Dates
DATEMOV: Moving a Date to a Significant Point DOWK and DOWKL: Finding the Day of the
Week
DATETRAN: Formatting Dates in International
Formats DT Functions: Converting an Integer to a Date
FIYR: Obtaining the Financial Year GREGDT: Converting From Julian to Gregorian
Format
FIQTR: Obtaining the Financial Quarter
JULDAT: Converting From Gregorian to Julian
FIYYQ: Converting a Calendar Date to a
Format
Financial Date
YM: Calculating Elapsed Months
TODAY: Returning the Current Date
Functions Reference 93
Overview of Date Functions
When using standard date functions, you need to understand the settings that alter the
behavior of these functions, as well as the acceptable formats and how to supply values in
these formats.
94 iWay Software
6. Date Functions
You can affect the behavior of date functions in the following ways:
Defining which days of the week are work days and which are not. Then, when you use
a date function involving work days, dates that are not work days are ignored. For details,
see Specifying Work Days on page 95.
Determining whether to display leading zeros when a date function in Dialogue Manager
returns a date. For details, see Enabling Leading Zeros For Date and Time Functions in
Dialogue Manager on page 98.
For detailed information on each standard date function, see:
DATEADD: Adding or Subtracting a Date Unit to or From a Date on page 99
DATECVT: Converting the Format of a Date on page 101
DATEDIF: Finding the Difference Between Two Dates on page 103
DATEMOV: Moving a Date to a Significant Point on page 105
DATETRAN: Formatting Dates in International Formats on page 107
FIYR: Obtaining the Financial Year on page 121
FIQTR: Obtaining the Financial Quarter on page 123
FIYYQ: Converting a Calendar Date to a Financial Date on page 125
TODAY: Returning the Current Date on page 127
In this section:
Specifying Business Days
Specifying Holidays
You can determine which days are work days and which are not. Work days affect the
DATEADD, DATEDIF, and DATEMOV functions. You identify work days as business days or
holidays.
Functions Reference 95
Using Standard Date Functions
How to:
Set Business Days
View the Current Setting of Business Days
Business days are traditionally Monday through Friday, but not every business has this
schedule. For example, if your company does business on Sunday, Tuesday, Wednesday,
Friday, and Saturday, you can tailor business day units to reflect that schedule.
96 iWay Software
6. Date Functions
Specifying Holidays
How to:
Create a Holiday File
Select a Holiday File
Reference:
Rules for Creating a Holiday File
You can specify a list of dates that are designated as holidays in your company. These dates
are excluded when using functions that perform calculations based on working days. For
example, if Thursday in a given week is designated as a holiday, the next working day after
Wednesday is Friday.
To define a list of holidays, you must:
1. Create a holiday file using a standard text editor.
2. Select the holiday file by issuing the SET command with the HDAY parameter.
Functions Reference 97
Using Standard Date Functions
Enabling Leading Zeros For Date and Time Functions in Dialogue Manager
How to:
Set the Display of Leading Zeros
If you use a date and time function in Dialogue Manager that returns a numeric integer
format, Dialogue Manager truncates any leading zeros. For example, if a function returns
the value 000101 (indicating January 1, 2000), Dialogue Manager truncates the leading
zeros, producing 101, an incorrect date. To avoid this problem, use the LEADZERO parameter.
LEADZERO only supports an expression that makes a direct call to a function. An expression
that has nesting or another mathematical function always truncates leading zeros. For
example,
-SET &OUT = AYM(&IN, 1, 'I4')/100;
truncates leading zeros regardless of the LEADZERO parameter setting.
98 iWay Software
6. Date Functions
The DATEADD function adds a unit to or subtracts a unit from a full component date format.
A unit is one of the following:
Year.
Functions Reference 99
DATEADD: Adding or Subtracting a Date Unit to or From a Date
Month. If the calculation using the month unit creates an invalid date, DATEADD corrects
it to the last day of the month. For example, adding one month to October 31 yields
November 30, not November 31 since November has 30 days.
Day.
Weekday. When using the weekday unit, DATEADD does not count Saturday or Sunday.
For example, if you add one day to Friday, first DATEADD moves to the next weekday,
Monday, then it adds a day. The result is Tuesday.
Business day. When using the business day unit, DATEADD uses the BUSDAYS parameter
setting and holiday file to determine which days are working days and disregards the
rest. If Monday is not a working day, then one business day past Sunday is Tuesday.
See Specifying Holidays on page 97 for more information.
DATEADD requires a date to be in date format. Since Dialogue Manager interprets a date
as alphanumeric or numeric, and DATEADD requires a standard date stored as an offset
from the base date, do not use DATEADD with Dialogue Manager unless you first convert
the variable used as the input date to an offset from the base date.
increment
Integer
Is the number of date units added to or subtracted from date. If this number is not a
whole unit, it is rounded down to the next largest integer.
Note: DATEADD does not use an output argument. It uses the format of the date argument
for the result. As long as the result is a full component date, it can be assigned only to a
full component date field or to integer field.
The DATECVT function converts the field value of any standard date format or legacy date
format into a date foromat (offset from the base date), in the desired standard date format
or legacy date format. If you supply an invalid format, DATECVT returns a zero or a blank.
The DATEDIF function returns the difference between two full component standard dates in
units of a specified component. A component is one of the following:
Year. Using the year unit with DATEDIF yields the inverse of DATEADD. If subtracting one
year from date X creates date Y, then the count of years between X and Y is one.
Subtracting one year from February 29 produces the date February 28.
Month. Using the month component with DATEDIF yields the inverse of DATEADD. If
subtracting one month from date X creates date Y, then the count of months between X
and Y is one. If the to-date is the end-of-month, then the month difference may be rounded
up (in absolute terms) to guarantee the inverse rule.
If one or both of the input dates is the end of the month, DATEDIF takes this into account.
This means that the difference between January 31 and April 30 is three months, not
two months.
Day.
Weekday. With the weekday unit, DATEDIF does not count Saturday or Sunday when
calculating days. This means that the difference between Friday and Monday is one day.
Business day. With the business day unit, DATEDIF uses the BUSDAYS parameter setting
and holiday file to determine which days are working days and disregards the rest. This
means that if Monday is not a working day, the difference between Friday and Tuesday
is one day. See Rules for Creating a Holiday File on page 97 for more information.
DATEDIF returns a whole number. If the difference between two dates is not a whole number,
DATEDIF truncates the value to the next largest integer. For example, the number of years
between March 2, 2001, and March 1, 2002, is zero. If the end date is before the start
date, DATEDIF returns a negative number.
Since Dialogue Manager interprets a date as alphanumeric or numeric, and DATEDIF requires
a standard date stored as an offset from the base date, do not use DATEDIF with Dialogue
Manager unless you first convert the variable used as the input date to an offset from the
base date.
Note: DATEDIF does not use an output argument because for the result it uses the format
'I8'.
Tip: There is an alternative way to find the difference between dates. As long as any standard
date is presented internally as a whole number of the least significant component units (that
is, a number of days for full component dates, a number of months for YYM or MY format
dates, etc.), you can find the difference in these component units (not any units) directly,
without DATEDIF. For example, assume OLD_YYM_DT is a date field in format MYY and
NEW_YYM_DT is another date in format YYM. Note that the least significant component for
both formats is month, M. The difference in months, then, can be found by subtracting the
field OLD_YYM_DT from NEW_YYM_DT in the following statement:
MYDIFF/I8 = NEW_YYM_DT/YYM - OLD_YYM_DT;
Otherwise, non-full component standard dates or legacy dates should be converted to full
component standard dates before using DATEDIF.
A business day calculation is affected by the BUSDAYS and HDAY parameter settings.
Note: DATEMOV does not use an output argument; it uses the format of the date argument
for the result. As long as the result is a full component date, it can be assigned only to a
full component date field or to an integer field.
'(W)' Day of week component only (original format must have only
W component).
Two-Component Description
Input Type
Two-Component Description
Input Type
Three- Description
Component Input
Type
formatops
Is a string of zero or more formatting options enclosed in parentheses and single
quotation marks. The parentheses and quotation marks are required even if you do not
specify formatting options. Formatting options fall into the following categories:
Options for suppressing initial zeros in month or day numbers. Note: Zero suppression
replaces initial zeros with blanks spaces.
Options for translating month or day components to full or abbreviated uppercase or
default case (mixed-case or lowercase depending on the language) names.
Date delimiter options and options for punctuating a date with commas.
Valid options for suppressing initial zeros in month or day numbers are listed in the
following table. Note that the initial zero is replaced by a blank space:
WR Includes a full day of the week name at the start of the displayed
date, all uppercase.
wr Includes a full day of the week name at the start of the displayed
date. The name displays in the default case of the specified
language (for example, all lowercase for French and Spanish,
initial uppercase for English and German).
XR Includes a full day of the week name at the end of the displayed
date, all uppercase.
xr Includes a full day of the week name at the end of the displayed
date. The name displays in the default case of the specified
language (for example, all lowercase for French and Spanish,
initial uppercase for English and German).
c Places a comma after the month name (following T, Tp, TR, t, tp,
or tr).
Places a comma and blank after the day name (following W, Wp,
WR, w, wp, or wr).
Places a comma and blank before the day name (following X, XR,
x, or xr).
D Inserts a comma after the day number and before the general
delimiter character specified.
Y Inserts a comma after the year and before the general delimiter
character specified.
lang
Is the two-character standard ISO code for the language into which the date should be
translated, enclosed in single quotation marks. Valid language codes are:
'AR' Arabic
'CS' Czech
'DA' Danish
'DE' German
'EN' English
'ES' Spanish
'FI' Finnish
'FR' French
'EL' Greek
'IW' Hebrew
'IT' Italian
'JA' Japanese
'KO' Korean
'LT' Lithuanian
'NL' Dutch
'NO' Norwegian
'PO' Polish
'PT' Portuguese
'RU' Russian
'SV' Swedish
'TH' Thai
'TR' Turkish
'TW' Chinese (Traditional)
'ZH' Chinese (Simplified)
outlen
Numeric
Is the length of the output field in bytes. If the length is insufficient, an all blank result
is returned. If the length is greater than required, the field is padded with blanks on the
right.
output
Alphanumeric
Valid translated date components are contained in files named DTLNGlng where lng is
a three-character code that specifies the language. These files must be accessible for
each language into which you want to translate dates.
The DATETRAN function is not supported in Dialogue Manager.
The following request prints a blank delimited date with an abbreviated month name in
English. Initial zeros in the day number are suppressed, and a suffix is added to the end of
the number:
DEFINE FILE VIDEOTRK
TRANS1/YYMD=20050104;
TRANS2/YYMD=20050302;
DATEW/W=TRANS1 ;
DATEW2/W=TRANS2 ;
DATEYYMD/YYMDW=TRANS1 ;
DATEYYMD2/YYMDW=TRANS2 ;
OUT2A/A15=DATETRAN(DATEYYMD, '(MDYY)', '(Btdo)', 'EN', 15, 'A15') ;
OUT2B/A15=DATETRAN(DATEYYMD2, '(MDYY)', '(Btdo)', 'EN', 15, 'A15') ;
END
TABLE FILE VIDEOTRK
HEADING
"FORMAT Btdo"
""
"Blank-delimited (B)"
"Abbreviated month name, default case (t)"
"Zero-suppress day number, end with suffix (do)"
"English"
""
SUM OUT2A AS '' OUT2B AS '' TRANSDATE NOPRINTON TABLE SET PAGE-NUM OFF
END
The following request prints a blank delimited date with an abbreviated month name in
German. Initial zeros in the day number are suppressed, and a period is added to the end
of the number:
DEFINE FILE VIDEOTRK
TRANS1/YYMD=20050104;
TRANS2/YYMD=20050302;
DATEW/W=TRANS1 ;
DATEW2/W=TRANS2 ;
DATEYYMD/YYMDW=TRANS1 ;
DATEYYMD2/YYMDW=TRANS2 ;
OUT3A/A12=DATETRAN(DATEYYMD, '(DMYY)', '(Btdp)', 'DE', 12, 'A12');
OUT3B/A12=DATETRAN(DATEYYMD2, '(DMYY)', '(Btdp)', 'DE', 12, 'A12');
END
TABLE FILE VIDEOTRK
HEADING
"FORMAT Btdp"
""
"Blank-delimited (B)"
"Abbreviated month name, default case (t)"
"Zero-suppress day number, end with period (dp)"
"German"
""
SUM OUT3A AS '' OUT3B AS '' TRANSDATE NOPRINT
ON TABLE SET PAGE-NUM OFF
END
The following request prints a blank delimited date in French with a full day name at the
beginning and a full month name, in lowercase (the default for French):
DEFINE FILE VIDEOTRK
TRANS1/YYMD=20050104;
TRANS2/YYMD=20050302;
DATEW/W=TRANS1 ;
DATEW2/W=TRANS2 ;
DATEYYMD/YYMDW=TRANS1 ;
DATEYYMD2/YYMDW=TRANS2 ;
OUT4A/A30 = DATETRAN(DATEYYMD, '(DMYY)', '(Bwrtr)', 'FR', 30, 'A30');
OUT4B/A30 = DATETRAN(DATEYYMD2, '(DMYY)', '(Bwrtr)', 'FR', 30, 'A30');
END
TABLE FILE VIDEOTRK
HEADING
"FORMAT Bwrtr"
""
"Blank-delimited (B)"
"Full day of week name at beginning of date, default case (wr)"
"Full month name, default case (tr)"
"English"
""
SUM OUT4A AS '' OUT4B AS '' TRANSDATE NOPRINT
ON TABLE SET PAGE-NUM OFF
END
The following request prints a blank delimited date in Spanish with a full day name at the
beginning in lowercase (the default for Spanish) followed by a comma, and with the word
“de” between the day number and month and between the month and year:
DEFINE FILE VIDEOTRK
TRANS1/YYMD=20050104;
TRANS2/YYMD=20050302;
DATEW/W=TRANS1 ;
DATEW2/W=TRANS2 ;
DATEYYMD/YYMDW=TRANS1 ;
DATEYYMD2/YYMDW=TRANS2 ;
OUT5A/A30=DATETRAN(DATEYYMD, '(DMYY)', '(Bwrctrde)', 'ES', 30, 'A30');
OUT5B/A30=DATETRAN(DATEYYMD2, '(DMYY)', '(Bwrctrde)', 'ES', 30, 'A30');
END
TABLE FILE VIDEOTRK
HEADING
"FORMAT Bwrctrde"
""
"Blank-delimited (B)"
"Full day of week name at beginning of date, default case (wr)"
"Comma after day name (c)"
"Full month name, default case (tr)"
"Zero-suppress day number (d)"
"de between day and month and between month and year (e)"
"Spanish"
""
SUM OUT5A AS '' OUT5B AS '' TRANSDATE NOPRINT
ON TABLE SET PAGE-NUM OFF
END
The following request prints a date in Japanese characters with a full month name at the
beginning, in the default case and with zero suppression:
DEFINE FILE VIDEOTRK
TRANS1/YYMD=20050104;
TRANS2/YYMD=20050302;
DATEW/W=TRANS1 ;
DATEW2/W=TRANS2 ;
DATEYYMD/YYMDW=TRANS1 ;
DATEYYMD2/YYMDW=TRANS2 ;
OUT6A/A30=DATETRAN(DATEYYMD , '(YYMD)', '(Ktrd)', 'JA', 30, 'A30');
OUT6B/A30=DATETRAN(DATEYYMD2, '(YYMD)', '(Ktrd)', 'JA', 30, 'A30');
END
TABLE FILE VIDEOTRK
HEADING
"FORMAT Ktrd"
""
"Japanese characters (K in conjunction with the language code JA)"
"Full month name at beginning of date, default case (tr)"
"Zero-suppress day number (d)"
"Japanese"
""
SUM OUT6A AS '' OUT6B AS '' TRANSDATE NOPRINT
ON TABLE SET PAGE-NUM OFF
END
The following request prints a blank delimited date in Greek with a full day name at the
beginning in the default case followed by a comma, and with a full month name in the default
case:
DEFINE FILE VIDEOTRK
TRANS1/YYMD=20050104;
TRANS2/YYMD=20050302;
DATEW/W=TRANS1 ;
DATEW2/W=TRANS2 ;
DATEYYMD/YYMDW=TRANS1 ;
DATEYYMD2/YYMDW=TRANS2 ;
OUT7A/A30=DATETRAN(DATEYYMD , '(DMYY)', '(Bwrctr)', 'GR', 30, 'A30');
OUT7B/A30=DATETRAN(DATEYYMD2, '(DMYY)', '(Bwrctr)', 'GR', 30, 'A30');
END
TABLE FILE VIDEOTRK
HEADING
"FORMAT Bwrctrde"
""
"Blank-delimited (B)"
"Full day of week name at beginning of date, default case (wr)"
"Comma after day name (c)"
"Full month name, default case (tr)"
"Greek"
""
SUM OUT7A AS '' OUT7B AS '' TRANSDATE NOPRINT
ON TABLE SET PAGE-NUM OFF
END
The FIYR function returns the financial year, also known as the fiscal year, corresponding to
a given calendar date based on the financial year starting date and the financial year
numbering convention.
Since Dialogue Manager interprets a date as alphanumeric or numeric, and FIYR requires a
standard date stored as an offset from the base date, do not use FIYR with Dialogue Manager
unless you first convert the variable used as the input date to an offset from the base date.
lowcomponent
Alphanumeric
Is one of the following:
D if the date contains a D or JUL component.
startmonth
Numeric
1 through 12 are used to represent the starting month of the financial year, where 1
represents January and 12 represents December. If the low component is Q, the start
month must be 1, 4, 7, or 10.
startday
Numeric
Is the starting day of the starting month, usually 1. If the low component is M or Q, 1 is
required.
yrnumbering
Alphanumeric
Valid values are:
FYE to specify the Financial Year Ending convention. The financial year number is the
calendar year of the ending date of the financial year. For example, when the financial
year starts on October 1, 2008, the date 2008 November 1 is in FY 2009 Q1 because
that date is in the financial year that ends on 2009 September 30.
FYS to specify the Financial Year Starting convention. The financial year number is the
calendar year of the starting date of the financial year. For example, when the financial
year starts on April 6, 2008, the date 2008 July 6 is in FY 2008 Q2 because that date
is in the financial year that starts on 2008 April 6.
output
I, Y, or YY
The result will be in integer format, or Y or YY. This function returns a year value. In case
of an error, zero is returned.
Note: February 29 cannot be used as a start day for a financial year.
The FIQTR function returns the financial quarter corresponding to a given calendar date
based on the financial year starting date and the financial year numbering convention.
Since Dialogue Manager interprets a date as alphanumeric or numeric, and FIQTR requires
a standard date stored as an offset from the base date, do not use FIQTR with Dialogue
Manager unless you first convert the variable used as the input date to an offset from the
base date.
startmonth
Numeric
1 through 12 are used to represent the starting month of the financial year, where 1
represents January and 12 represents December. If the low component is Q, the start
month must be 1, 4, 7, or 10.
startday
Numeric
Is the starting day of the starting month, usually 1. If the low component is M or Q, 1 is
required.
yrnumbering
Alphanumeric
Valid values are:
FYE to specify the Financial Year Ending convention. The financial year number is the
calendar year of the ending date of the financial year. For example, when the financial
year starts on October 1, 2008, the date 2008 November 1 is in FY 2009 Q1 because
that date is in the financial year that ends on 2009 September 30.
FYS to specify the Financial Year Starting convention. The financial year number is the
calendar year of the starting date of the financial year. For example, when the financial
year starts on April 6, 2008, the date 2008 July 6 is in FY 2008 Q2 because that date
is in the financial year that starts on 2008 April 6.
output
I or Q
The result will be in integer format, or Q. This function will return a value of 1 through
4. In case of an error, zero is returned.
Note: February 29 cannot be used as a start day for a financial year.
The FIYYQ function returns a financial date containing both the financial year and quarter
that corresponds to a given calendar date. The returned financial date is based on the
financial year starting date and the financial year numbering convention.
Since Dialogue Manager interprets a date as alphanumeric or numeric, and FIYYQ requires
a standard date stored as an offset from the base date, do not use FIYYQ with Dialogue
Manager unless you first convert the variable used as the input date to an offset from the
base date.
startmonth
Numeric
1 through 12 are used to represent the starting month of the financial year, where 1
represents January and 12 represents December. If the low component is Q, the start
month must be 1, 4, 7, or 10.
startday
Numeric
Is the starting day of the starting month, usually 1. If the low component is M or Q, 1 is
required.
yrnumbering
Alphanumeric
Valid values are:
FYE to specify the Financial Year Ending convention. The financial year number is the
calendar year of the ending date of the financial year. For example, when the financial
year starts on October 1, 2008, the date 2008 November 1 is in FY 2009 Q1 because
that date is in the financial year that ends on 2009 September 30.
FYS to specify the Financial Year Starting convention. The financial year number is the
calendar year of the starting date of the financial year. For example, when the financial
year starts on April 6, 2008, the date 2008 July 6 is in FY 2008 Q2 because that date
is in the financial year that starts on 2008 April 6.
output
Y[Y]Q or QY[Y]
In case of an error, zero is returned.
Note: February 29 cannot be used as a start day for a financial year.
The TODAY function retrieves the current date from the operating system in the format
MM/DD/YY or MM/DD/YYYY. It always returns a date that is current. Therefore, if you are
running an application late at night, use TODAY. You can remove the default embedded
slashes with the EDIT function.
You can also retrieve the date in the same format (separated by slashes) using the Dialogue
Manager system variable &DATE. You can retrieve the date without the slashes using the
system variables &YMD, &MDY, and &DMY. The system variable &DATEfmt retrieves the
date in a specified format.
The legacy date functions were created for use with dates in integer, packed decimal, or
alphanumeric format.
How to:
Activate Old Legacy Date Functions
The functions described in this section are legacy date functions. They were created for use
with dates in integer or alphanumeric format. They are no longer recommended for date
manipulation. Standard date and date-time functions are preferred.
All legacy date functions support dates for the year 2000 and later. The old versions of these
functions may not work correctly with dates after December 31, 1999. However, in some
cases you may want to use the old version of a function, for example, if you do not use year
2000 dates. You can "turn off" the current version with the DATEFNS parameter.
The AYM function adds months to or subtracts months from a date in year-month format.
You can convert a date to this format using the CHGDAT or EDIT function.
The AYMD function adds days to or subtracts days from a date in year-month-day format.
You can convert a date to this format using the CHGDAT or EDIT function.
The CHGDAT function rearranges the year, month, and day portions of an input character
string representing a date. It may also convert the input string from long to short or short
to long date representation. Long representation contains all three date components: year,
month, and day; short representation omits one or two of the date components, such as
year, month, or day. The input and output date strings are described by display options that
specify both the order of date components (year, month, day) in the date string and whether
two or four digits are used for the year (for example, 04 or 2004). CHGDAT reads an input
date character string and creates an output date character string that represents the same
date in a different way.
Note: CHGDAT requires a date character string as input, not a date itself. Whether the input
is a standard or legacy date, convert it to a date character string (using the EDIT or DATECVT
functions, for example) before applying CHGDAT.
The order of date components in the date character string is described by display options
comprised of the following characters in your chosen order:
Character Description
Y[Y] Year. Y indicates a two-digit year (such as 94); YY indicates a four-digit year
(such as 1994).
To spell out the month rather than use a number in the resulting string, append one of the
following characters to the display options for the resulting string:
Character Description
Display options can consist of up to five display characters. Characters other than those
display options are ignored.
For example: The display options 'DMYY' specify that the date string starts with a two digit
day, then two digit month, then four digit year.
Note: Display options are not date formats.
Month (for example, from Y to YM) Last month of the year (December).
Converting year from two-digit to four- If DATEFNS=ON, the century will be determined
digit (for example, from YMD to YYMD) by the 100-year window defined by DEFCENT
and YRTHRESH.
If DATEFNS=OFF, the year 19xx is supplied,
where xx is the last two digits in the year.
'out_display_options'
A1 to A5
Is a series of up to five display options that describe the layout of the converted date
string. These options can be stored in an alphanumeric field or supplied as a literal
enclosed in single quotation marks.
date_string
A2 to A8
Is the input date character string with date components in the order specified by
in_display_options.
Note that if the original date is in numeric format, you must convert it to a date character
string. If date_string does not correctly represent the date (the date is invalid), the
function returns blank spaces.
output
Axx, where xx is a number of characters large enough to fit the date string specified by
out_display_options. A17 is long enough to fit the longest date string.
Note: Since CHGDAT uses a date string (as opposed to a date) and returns a date string
with up to 17 characters, use the EDIT or DATECVT functions or any other means to convert
the date to or from a date character string.
The DA functions convert a legacy date to the number of days between it and a base date.
By converting a date to the number of days, you can add and subtract dates and calculate
the intervals between themthem, or you can add to or subtract numbers from the dates to
get new dates.
You can convert the result back to a date using the DT functions discussed in DT Functions:
Converting an Integer to a Date on page 136.
There are six DA functions; each one accepts a date in a different format.
indate
I6xxx or P6xxx, where xxx corresponds to the function DAxxx you are using.
Is the legacy date to be converted. If indate is a numeric literal, enter only the last two
digits of the year; the function assumes the century component. If the date is invalid,
the function returns a 0.
output
Integer
The DMY, MDY, and YMD functions calculate the difference between two legacy dates in
integer, alphanumeric, or packed format.
from_date
I, P, or A format with date display options.
Is the beginning legacy date,.
to_date
I, P, or A format with date display options.I6xxx or I8xxx where xxx corresponds to the
specified function (DMY, YMD, or MDY).
Is the end date.
The DOWK and DOWKL functions find the day of the week that corresponds to a date. DOWK
returns the day as a three letter abbreviation; DOWKL displays the full name of the day.
There are six DT functions; each one converts a number into a date of a different format.
number
Integer
Is the number of days since the base date, possibly received from the functions DAxxx.
output
I8xxx, where xxx corresponds to the function DTxxx in the above list.
The GREGDT function converts a date in Julian format (year-day) to Gregorian format (year-
month-day).
A date in Julian format is a five- or seven-digit number. The first two or four digits are the
year; the last three digits are the number of the day, counting from January 1. For example,
January 1, 1999 in Julian format is either 99001 or 1999001; June21, 2004 in Julian format
is 2004173.
The JULDAT function converts a date from Gregorian format (year-month-day) to Julian format
(year-day). A date in Julian format is a five- or seven-digit number. The first two or four digits
are the year; the last three digits are the number of the day, counting from January 1. For
example, January 1, 1999 in Julian format is either 99001 or 1999001.
The YM function calculates the number of months between two dates. The dates must be
in year-month format. You can convert a date to this format by using the CHGDAT or EDIT
function.
todate
I4YM or I6YYM
Is the end date in year-month format. If the date is not valid, the function returns the
value 0 (zero).
output
Integer
Tip: If fromdate or todate is in integer year-month-day format (I6YMD or I8YYMD), simply
divide by 100 to convert to year-month format and set the result to an integer. This drops
the day portion of the date, which is now after the decimal point.
7 Date-Time Functions
Date-Time functions are for use with timestamps in date-time formats, also known as H formats. A
timestamp value refers to internally stored data capable of holding both date and time components with
an accuracy of up to a nanosecond.
Topics:
HINPUT: Converting an Alphanumeric String to
a Date-Time Value
Using Date-Time Functions
HMIDNT: Setting the Time Portion of a
HADD: Incrementing a Date-Time Value
Date-Time Value to Midnight
HCNVRT: Converting a Date-Time Value to
HNAME: Retrieving a Date-Time Component in
Alphanumeric Format
Alphanumeric Format
HDATE: Converting the Date Portion of a
HPART: Retrieving a Date-Time Component as
Date-Time Value to a Date Format
a Numeric Value
HDIFF: Finding the Number of Units Between
HSETPT: Inserting a Component Into a
Two Date-Time Values
Date-Time Value
HDTTM: Converting a Date Value to a
HTIME: Converting the Time Portion of a
Date-Time Value
Date-Time Value to a Number
HGETC: Storing the Current Date and Time in
HTMTOTS: Converting a Time to a Timestamp
a Date-Time Field
HYYWD: Returning the Year and Week Number
HHMMSS: Retrieving the Current Time
From a Date-Time Value
The functions described in this section operate on fields in date-time format (sometimes
called H format).
However, you can also provide a date as a character string using the macro DT, followed by
a character string in parentheses, presenting date and time. Date components are separated
by slashes '/'; time components by colons ':'.
Alternatively, the day can be given as a natural day, like 2004 March 31, in parentheses.
Either the date or time component can be omitted. For example, the date-time format
argument can be expressed as DT(2004/03/11 13:24:25.99) or DT(March 11 2004).
The following is another example that creates a timestamp representing the current date
and time. The system variables &YYMD and &TOD are used to obtain the current date and
time, respectively:
-SET &MYSTAMP = &YYMD | ' ' | EDIT(&TOD,'99:$99:$99') ;
Today's date (&YYMD) is concatenated with the time of day (&TOD). The EDIT function is
used to change the dots (.) in the time of day variable to colons (:).
The following request uses the DT macro on the alphanumeric date and time variable
&MYSTAMP:
TABLE FILE CAR
PRINT CAR NOPRINT
COMPUTE DTCUR/HYYMDS = DT(&MYSTAMP);
IF RECORDLIMIT IS 1;
END
Date-Time Parameters
In this section:
Specifying the Order of Date Components
Specifying the First Day of the Week for Use in Date-Time Functions
Controlling Processing of Date-Time Values
The DATEFORMAT parameter specifies the order of the date components for certain types
of date-time values. The WEEKFIRST parameter specifies the first day of the week. The
DTSTRICT parameter determines the extent to which date-time values are checked for validity.
How to:
Specify the Order of Date Components in a Date-Time Field
The DATEFORMAT parameter specifies the order of the date components (month/day/year)
when date-time values are entered in the formatted string and translated string formats. It
makes the input format of a value independent of the format of the variable to which it is
being assigned.
Specifying the First Day of the Week for Use in Date-Time Functions
How to:
Set a Day as the Start of the Week
View the Current Setting of WEEKFIRST
The WEEKFIRST parameter specifies a day of the week as the start of the week. This is used
in week computations by the HDIFF, HNAME, HPART, and HSETPT functions. The WEEKFIRST
parameter does not change the day of the month that corresponds to each day of the week,
but only specifies which day is considered the start of the week.
The HPART, HYYWD, and HNAME subroutines can extract a week number from a date-time
value. To determine a week number, they can use ISO 8601 standard week numbering,
which defines the first week of the year as the first week in January with four or more days.
Any preceding days in January belong to week 52 or 53 of the preceding year. The ISO
standard also establishes Monday as the first day of the week.
These functions can also define the first week of the year as the first week in January with
seven days. This is the definition they used in prior releases.
You specify which type of week numbering to use by setting the WEEKFIRST parameter.
Since the week number returned by HNAME and HPART functions can be in the current year
or the year preceding or following, the week number by itself may not be useful. The function
HYYWD returns both the year and the week from a given date-time value.
How to:
Enable Strict Processing of Date-Time Values
Strict processing checks date-time values when they are input by an end user, read from a
transaction file, displayed, or returned by a subroutine to ensure that they represent a valid
date and time. For example, a numeric month must be between 1 and 12, and the day must
be within the number of days for the specified month.
Reference:
Arguments for Use With Date and Time Functions
Date-time functions may operate on a component of a date-time value. This topic lists the
valid component names and abbreviations for use with thes functions.
year yy 0001-9999
quarter qq 1-4
day-of-year dy 1-366
week wk 1-53
hour hh 0-23
minute mi 0-59
second ss 0-59
millisecond ms 0-999
microsecond mc 0-999999
nanosecond ns 0-999999999
Note:
For an argument that specifies a length of eight, ten, or 12 characters, use eight to
include milliseconds, ten to include microseconds, and 12 to include nanoseconds in
the returned value.
The last argument is always a USAGE format that indicates the data type returned by the
function. The type may be A (alphanumeric), I (integer), D (floating-point double precision),
H (date-time), or a date format (for example, YYMD).
length
Integer
Is the number of characters returned. Valid values are:
8 indicates a date-time value that includes one to three decimal digits (milliseconds).
10 indicates a date-time value that includes four to six decimal digits (microseconds).
12 indicates a date-time value that includes seven to nine decimal digits (nanoseconds).
output
Date-time
The HCNVRT function converts a date-time value to alphanumeric format for use with operators
such as EDIT, CONTAINS, and LIKE.
length
Integer
Is the number of characters in the alphanumeric field that is returned. If length is smaller
than the number of characters needed to display the alphanumeric field, the function
returns a blank.
output
Alphanumeric
The HDATE function converts the date portion of a date-time value to the date format YYMD.
You can then convert the result to other date formats.
Syntax: How to Convert the Date Portion of a Date-Time Value to a Date Format
HDATE(datetime, output
where:
datetime
Date-time
Is the date-time value to be converted.
output
Date
The HDIFF function calculates the number of date or time component units between two
date-time values.
Syntax: How to Find the Number of Units Between Two Date-Time Values
HDIFF(end_dt, start_dt, 'component', output)
where:
end_dt
Date-time
Is the date-time value to subtract from.
start_dt
Date-time
Is the date-time value to subtradt.
component
Alphanumeric
Is the name of the component to be used in the calculation, enclosed in single quotation
marks. If the component is a week, the WEEKFIRST parameter setting is used in the
calculation.
output
Floating-point double-precision
The HDTTM function converts a date value to a date-time value. The time portion is set to
midnight.
length
Integer
Is the length of the returned date-time value. Valid values are:
8 indicates a time value that includes milliseconds.
output
Date-time
Is the generated date-time value. The value must have a date-time format (data type H).
The HGETC function returns the current date and time in the desired date-time format. If
millisecond or microsecond values are not available in your operating environment, the
function retrieves the value zero for these components.
Syntax: How to Store the Current Date and Time in a Date-Time Field
HGETC(length, output)
where:
length
Integer
Is the length of the returned date-time value. Valid values are:
8 indicates a time value that includes milliseconds.
output
Date-time
Is the returned date-time value.
The HHMMSS function retrieves the current time from the operating system as an eight
character string, separating the hours, minutes, and seconds with periods.
10 indicates a time value that includes four to six decimal digits (microseconds).
12 indicates a time value that includes seven to nine decimal digits (nanoseconds).
output
Date-time
Is the returned date-time value.
The HMIDNT function changes the time portion of a date-time value to midnight (all zeros
by default). This allows you to compare a date field with a date-time field.
output
Date-time
Is the date-time return value whose time is set to midnight and whose date is copied
from timestamp.
The HNAME function extracts a specified component from a date-time value and returns it
as digits in alphanumeric format.
output
Alphanumeric, at least A2
The function converts all other components to strings of digits only. The year is always
four digits, and the hour assumes the 24-hour system.
The HPART function extracts a specified component from a date-time value and returns it in
numeric format.
output
Integer
The HSETPT function inserts the numeric value of a specified component into a date-time
value.
length
Integer
Is the length of the returned date-time value. Valid values are:
8 indicates a time value that includes one to three decimal digits (milliseconds).
10 indicates a time value that includes four to six decimal digits (microseconds).
12 indicates a time value that includes seven to nine decimal digits (nanoseconds).
output
Date-time
Is the retruned date-time value whose chosen component is updated. All other
components are copied from the source date-time value.
The HTIME function converts the time portion of a date-time value to the number of
milliseconds if the lengrh argument is eight, microseconds if the length argument is ten, or
nanoseconds if the length argument is 12.
10 indicates a time value that includes four to six decimal digits (microseconds).
12 indicates a time value that includes seven to nine decimal digits (nanoseconds).
datetime
Date-time
Is the date-time value from which to convert the time.
output
Floating-point double-precision
The HTMTOTS function returns a timestamp using the current date to supply the date
components of its value, and copies the time components from its input date-time value.
output_format
Date-Time
Is the timestamp whose date is set to current date, and whose time is copied from time.
HYYWD: Returning the Year and Week Number From a Date-Time Value
How to:
Return the Year and Week Number From a Date-Time Value
The week number returned by HNAME and HPART can actually be in the year preceding or
following the input date.
The HYYWD function returns both the year and the week number from a given date-time
value.
The output is edited to conform to the ISO standard format for dates with week numbers,
yyyy-Www-d.
Syntax: How to Return the Year and Week Number From a Date-Time Value
HYYWD(dtvalue, output)
where:
dtvalue
Date-time
Is the date-time value to be edited.
output
Alphanumeric
The output format must be at least 10 characters long. The output is in the following
format:
yyyy-Www-d
where:
yyyy
Is the four-digit year.
ww
Is the two-digit week number (01 to 53).
d
Is the single-digit day of the week (1 to 7). The d value is relative to the current
WEEKFIRST setting. If WEEKFIRST is 2 or ISO2 (Monday), then Monday is represented
in the output as 1, Tuesday as 2.
Using the EDIT function, you can extract the individual subfields from this output.
Example: Returning the Year and Week Number From a Date-time Value
The following converts the TRANSDATE date-time value to the ISO standard format for dates
with week numbers. WEEKFIRST is set to ISO2, which produces ISO standard week numbering:
ISODATE/A10 = HYYWD(TRANSDATE, 'A10');
For date component 1999/01/30 04:16, the value is 1999-W04-6.
For date component 1999/12/15, the value is 1999-W50-3.
The EDIT function converts an alphanumeric field that contains numeric characters to numeric
format or converts a numeric field to alphanumeric format.
This function is usefule for manipulating a field in an expression that performs an operation
that requires operands in a particular format.
When EDIT assigns a converted value to a new field, the format of the new field must
correspond to the format of the returned value. For example, if EDIT converts a numeric field
to alphanumeric format, you must give the new field an alphanumeric format:
DEFINE ALPHAPRICE/A6 = EDIT(PRICE);
EDIT deals with a symbol in the following way:
When an alphanumeric field is converted to numeric format, a sign or decimal point in
the field is stored as part of the numeric value.
Any other non-numeric characters are invalid, and EDIT returns the value zero.
When converting a floating-point or packed-decimal field to alphanumeric format, EDIT
removes the sign, the decimal point, and any number to the right of the decimal point.
It then right-justifies the remaining digits and adds leading zeros to achieve the specified
field length. Converting a number with more than nine significant digits in floating-point
or packed-decimal format may produce an incorrect result.
EDIT also extracts characters from or add characters to an alphanumeric string. For more
information, see EDIT: Extracting or Adding Characters on page 37.
The FPRINT function converts any type of field except for a text field to its alphanumeric
equivalent for display. The alphanumeric representation will include any display options that
are specified in the format of the original field.
For example, D12.2 format is converted to A14 because it outputs two decimal digits,
a decimal point, a possible minus sign, up to eight integer digits, and two commas. If
the output format is not large enough, excess right-hand characters may be truncated.
The FTOA function converts a number up to 16 digits long from numeric format to
alphanumeric format. It retains the decimal positions of the number and right-justifies it with
leading spaces. You can also add edit options to a number converted by FTOA.
When using FTOA to convert a number containing decimals to a character string, you must
specify an alphanumeric format large enough to accommodate both the integer and decimal
portions of the number. For example, a D12.2 format is converted to A14. If the output
format is not large enough, decimals are truncated.
format
Alphanumeric
Is the format of the number to be converted enclosed in parentheses. Only floating point
single-precision and double-precision formats are supported. Include any edit options
that you want to appear in the output. The D (floating-point double-precision) format
automatically supplies commas.
output
Alphanumeric
The length of this argument must be greater than the length of number and must account
for edit options and a possible negative sign.
The HEXBYT function obtains the ASCII, EBCDIC, or Unicode character equivalent of a decimal
integer, depending on your configuration and operating environment. It returns a single
alphanumeric character in the ASCII, EBCDIC, or Unicode character set. You can use this
function to produce characters that are not on your keyboard, similar to the CTRAN function.
In Unicode configurations, this function uses values in the range:
0 to 255 for 1-byte characters.
256 to 65535 for 2-byte characters.
65536 to 16777215 for 3-byte characters.
16777216 to 4294967295 for 4-byte characters (primarily for EBCDIC).
The display of special characters depends on your software and hardware; not all special
characters may appear. For printable ASCII and EBCDIC characters and their integer
equivalents see the Character Chart for ASCII and EBCDIC on page 19.
The ITONUM function converts a large number in a non-FOCUS data source from special long
integer to double-precision format.
This is useful for some programming languages and some non-FOCUS data storage systems
that use special long integers, which do not fit the regular integer format (four bytes in length)
supported in the synonym, and, therefore, require conversion to double-precision format.
You must specify how many of the right-most bytes in the input field are significant. The
result is an 8-byte double-precision field.
Is the maximum number of bytes in the 8-byte binary input field that have significant
numeric data, including the binary sign. Valid values are:
5 ignores the left-most 3 bytes.
The ITOPACK function converts a large binary integer in a non-FOCUS data source to packed-
decimal format.
This is useful for some programming languages and some non-FOCUS data storage systems
that use special long integers, which do not fit the regular integer format (four bytes in length)
supported in the synonym, and, therefore, require conversion to packed-decimal format.
You must specify how many of the right-most bytes in the input field are significant. The
result is an 8-byte packed-decimal field of up to 15 significant numeric positions (for example,
P15 or P16.2).
Limit: For a field defined as 'PIC 9(15) COMP' or the equivalent (15 significant digits), the
maximum number that can be converted is 167,744,242,712,576.
infield
A8
Is the field that contains the binary number. Both the USAGE and ACTUAL formats of
the field must be A8.
output
Numeric
The format must be Pn or Pn.d.
The ITOZ function converts a number in numeric format to zoned-decimal format. Although
a request cannot process zoned numbers, it can write zoned fields to an extract file for use
by an external program.
The PCKOUT function writes a packed-decimal number of variable length to an extract file.
When a request saves a packed number to an extract file, it typically writes it as an 8- or
16-byte field regardless of its format specification. With PCKOUT, you can vary the field's
length between 1 to 16 bytes.
length
Numeric
Is the length of the output value, from 1 to 16 bytes.
output
Alphanumeric
The function returns the field as alphanumeric although it contains packed data.
The PTOA function converts a number from numeric format to alphanumeric format. It retains
the decimal positions of the number and right-justifies it with leading spaces. You can also
add edit options to a number converted by PTOA.
When using PTOA to convert a number containing decimals to a character string, you must
specify an alphanumeric format large enough to accommodate both the integer and decimal
portions of the number. For example, a P12.2C format is converted to A14. If the output
format is not large enough, the right-most characters are truncated.
The UFMT function converts characters in an alphanumeric source string to their hexadecimal
representation. This function is useful for examining data of unknown format. As long as
you know the length of the data, you can examine its content.
9 Numeric Functions
Topics:
LOG: Calculating the Natural Logarithm
ABS: Calculating Absolute Value MAX and MIN: Finding the Maximum or
Minimum Value
CHKPCK: Validating a Packed Field
NORMSDST: Calculating Standard Cumulative
DMOD, FMOD, and IMOD: Calculating the
Normal Distribution
Remainder From a Division
NORMSINV: Calculating Inverse Cumulative
EXP: Raising e to the Nth Power
Normal Distribution
EXPN: Evaluating a Number in Scientific
PRDNOR and PRDUNI: Generating Reproducible
Notation
Random Numbers
INT: Finding the Greatest Integer
RDNORM and RDUNIF: Generating Random
Numbers
SQRT: Calculating the Square Root
The CHKPCK function validates the data in a field described as packed format (if available
on your platform). The function prevents a data exception from occurring when a request
reads a field that is expected to contain a valid packed number but does not.
To use CHKPCK:
1. Ensure that the Master File (USAGE and ACTUAL attributes) defines the field as
alphanumeric, not packed. This does not change the field data, which remains packed,
but it enables the request to read the data without a data exception.
2. Call CHKPCK to examine the field. The function returns the output to a field defined as
packed. If the value it examines is a valid packed number, the function returns the value;
if the value is not packed, the function returns an error code.
The MOD functions calculate the remainder from a division. Each function returns the
remainder in a different format.
The functions use the following formula.
remainder = dividend - INT(dividend/divisor) * divisor
The EXP function raises the value "e" (approximately 2.72) to a specified power. This function
is the inverse of the LOG function, which returns the logarithm of the argument.
EXP calculates the result by adding terms of an infinite series. If a term adds less than
.000001 percent to the sum, the function ends the calculation and returns the result as a
double-precision number.
The MAX and MIN functions return the maximum or minimum value, respectively, from a list
of values.
value1, value2
Numeric
Are the values for which the maximum or minimum value is returned. If you supply an
expression, use parentheses as needed to ensure the correct order of evaluation.
Note: MAX and MIN do not use an output argument. The format of the result is floating-point
double precision.
You can convert a value (raw score) from your normally distributed data to the equivalent
normalized value (z-score) as follows:
z = (raw_score - mean)/standard_deviation
To convert from a z-score back to a raw score, use the following formula:
raw_score = z * standard_deviation + mean
The mean of data points xi, where i is from 1 to n is:
The following diagram illustrates the results of the NORMSDST and NORMSINV functions.
Syntax: How to Calculate the Inverse Cumulative Standard Normal Distribution Function
NORMSINV(value, 'D8');
where:
value
Is a number between 0 and 1 (which represents a percentile in a standard normal
distribution).
D8
Is the required format for the result. The value returned by the function is double-precision.
You can assign it to a field with any valid numeric format.
seed
Numeric
Is the seed or the field that contains the seed, up to 9 digits. The seed is truncated to
an integer.
output
Double-precision
output
Double-precision
10 System Functions
The CLSDDREC function closes all files opened by the PUTDDREC function. If PUTDDREC is
called in a Dialogue Manager -SET command, the files opened by PUTDDREC are not closed
automatically until the end of a request or connection. In this case, you can close the files
and free the memory used to store information about open file by calling the CLSDDREC
function. For information about PUTDDREC, see PUTDDREC: Writing a Character String as a
Record in a Sequential File on page 196.
The FEXERR function retrieves an Information Builders error message. It is especially useful
in a procedure using a command that suppresses the display of output messages.
An error message consists of up to four lines of text. The first line contains the message
and the remaining three contain a detailed explanation, if one exists. FEXERR retrieves the
first line of the error message.
The FGETENV function retrieves the value of an environment variable and returns it as an
alphanumeric string.
outlen
Integer
Is the length of the environment variable value returned.
output
Alphanumeric
Available Operating Systems: IBM i (formerly referred to as i5/OS), Tandem, UNIX, Windows
The FPUTENV function assigns a character string to an environment variable.
Limit: You cannot use FPUTENV to set or change FOCPRINT, FOCPATH, or USERPATH; once
started, these variables are held in memory and not reread from the environment.
Is the value you wish to assign to the environment variable. The string must be right-
justified and contain no embedded blanks. Strings that contain embedded blanks are
truncated at the first blank.
output
Integer
Is the return code. If the variable is set successfully, the return code is 0; any other
value indicates a failure occurred.
The PUTDDREC function writes a character string as a record in a sequential file. The file
must be identified with a FILEDEF (DYNAM on z/OS) command. If the file is defined as an
existing file (with the APPEND option), the new record is appended. If the file is defined as
NEW and it already exists, the new record overwrites the existing file.
PUTDDREC opens the file if it is not already open. Each call to PUTDDREC can use the same
file or a new one. All of the files opened by PUTDDREC remain open until the end of a request
or connection. At the end of the request or connection, all files opened by PUTDDREC are
automatically closed. For information about closing files opened by PUTDDREC in order to
free the memory used, see CLSDDREC: Closing All Files Opened by the PUTDDREC Function
on page 192.
If PUTDDREC is called in a Dialogue Manager -SET command, the files opened by PUTDDREC
are not closed automatically until the end of a request or connection. In this case, you can
close the files and free the memory used to store information about open file by calling the
CLSDDREC function.
The SLEEP function suspends execution for the number of seconds you specify as its input
argument.
This function is only supported in Dialogue Manager. It is useful when you need to wait to
start a specific procedure or application.
The CONCAT function concatenates the values of two arguments. The result is a character
string consisting of the characters of the first argument followed by the characters of the
second argument.
The DIGITS function extracts the digits of a decimal or integer value into a character string.
The sign and decimal point of the number (if present) are ignored.
Note: This function is available for DB2, ORACLE, and MS SQL Server. It does not work for
flat file sources.
The EDIT function edits a numeric or character value according to a format specified by a
mask. (It works exactly like the EDIT function in FOCUS.)
A 9 in the mask indicates the corresponding character in the source value is copied into the
result. A $ in the mask indicates that the corresponding character is to be ignored. Any other
character is inserted into the result.
The LCASE function converts a character string value to lowercase. That is, capital letters
are replaced by their corresponding lowercase values.
LOWER and LOWERCASE are identical to LCASE.
The POSITION function returns the position within a character string of a specified substring.
If the substring does not appear in the character string, the result is 0. Otherwise, the value
returned is one greater than the number of characters in the string preceding the start of
the first occurrence of the substring.
This example,
POSITION ('IOU' IN 'AEIOU')
returns 3.
This example,
POSITION ('Y' IN 'AEIOU')
returns 0.
The SUBSTR function returns a substring of a character value. You specify the start position
of the substring within the value. You can also specify the length of the substring (if omitted,
the substring extends from the start position to the end of the string value). If the specified
length value is longer than the input string, the result is the full input string.
SUBSTRING is identical to SUBSTR.
or
SUBSTR(arg, start-pos [, length])
where:
arg
character string
Is the field containing the parent character string.
start-pos
Integer
Is the position within arg at which the substring begins.
length
Integer
If present, is the length of the substring. This function returns a varying character string.
The data type of the result has a length equal to that of the input argument (although
the value may be shorter).
This example,
SUBSTRING('ABC' FROM 1 FOR 2)
returns AB.
This example,
SUBSTR('ABC', 10)
returns ABC.
The TRIM function removes leading and/or trailing characters from a character string. The
character to be removed may be specified. If no character is specified, the space character
is assumed. Whether to remove leading and/or trailing characters may be specified. Without
this specification, both leading and trailing appearances of the specified character are
removed.
Value may be LEADING, TRAILING or BOTH. Indicates where characters will be removed.
If not specified, BOTH is assumed.
trim-char
character string
Is the character to be removed. If not specified, the space character is assumed.
This function returns a varying character string. The data type of the result has a length
equal to that of the input argument (although the value may be shorter).
The UCASE function converts a character string value to uppercase. That is, lowercase letters
are replaced by their corresponding uppercase values. UPPER and UPPERCASE are identical
to UCASE.
The VARGRAPHIC function converts the input value to double-byte character data
SQL date and time functions perform manipulations on date and time values.
Topics:
HOUR: Obtaining the Hour From
Time/Timestamp
CURRENT_DATE: Obtaining the Date
MICROSECOND: Obtaining Microseconds From
CURRENT_TIME: Obtaining the Time
Time/Timestamp
CURRENT_TIMESTAMP: Obtaining the
MILLISECOND: Obtaining Milliseconds From
Timestamp (Date/Time)
Time/Timestamp
DAY: Obtaining the Day of the Month From a
MINUTE: Obtaining the Minute From
Date/Timestamp
Time/Timestamp
DAYS: Obtaining the Number of Days Since
MONTH: Obtaining the Month From
January 1, 1900
Date/Timestamp
EXTRACT: Obtaining a Datetime Field From
SECOND: Obtaining the Second Field From
Date/Time/Timestamp
Time/Timestamp
YEAR: Obtaining the Year From
Date/Timestamp
The CURRENT_DATE function returns the current date of the operating system in the form
YYYYMMDD.
The CURRENT_TIME function returns the current time of the operating system in the form
HHMMSS. You may specify the number of decimal places for fractions of a second--0, 3, or
6 places. Zero (0) places is the default.
The CURRENT_TIMESTAMP function returns the current timestamp of the operating system
(date and time) in the form YYYYMMDDHHMMSS. You may specify the number of decimal
places for fractions of a second--0, 3, or 6 places. Six (6) places is the default.
The DAY function returns the day of the month from a date or timestamp value.
Syntax: How to Obtain the Day of the Month From a Date or Timestamp
DAY(arg)
where:
arg
Date or timestamp
Is the input value.
This function returns an integer value.
The DAYS function returns the number of days since January 1, 1900.
The EXTRACT function can be used to obtain the year, month, day of month, hour, minute,
second, millisecond, or microsecond component of a date, time, or timestamp value.
HOUR, MINUTE, SECOND, MILLISECOND and MICROSECOND can be used only if the
argument is time or timestamp.
The HOUR function returns the hour field from a time or timestamp value.
This example,
HOUR('2001-01-22 10:00:00')
returns 10.
The MICROSECOND function returns the number of microseconds from a time or timestamp
value.
The MILLISECOND function returns the number of milliseconds from a time or timestamp
value.
The MINUTE function returns the number of minutes from a time or timestamp value.
where:
arg
Time or timestamp
Is the input value.
This function returns an integer value.
The MONTH function returns the month field from a date or timestamp value.
The SECOND function returns the second field from a time or timestamp value.
The YEAR function returns the year field from a date or timestamp value.
The CAST function converts the value of its argument to a specified data type.
The DATE function converts its argument to a date. The type of the argument value may be
character, date, or timestamp.
If the argument is:
A character, its value must correctly represent a date; that date is the result.
A date, its value is returned.
A timestamp, the date portion of the timestamp value is returned.
The INT function converts a number to an integer. If the input value is not an integer, the
result is truncated.
The SMALLINT function converts a number to a small integer. Generally, a small integer
occupies only two bytes in memory.
The TIME function converts its argument to a time. The type of the argument value may be
character, time, or timestamp.
If the argument is a character, its value must correctly represent a time; that time is the
result.
If the argument is a time, its value is returned.
If the argument is a timestamp, the time portion of the timestamp value is returned.
The TIMESTAMP function converts its argument to a timestamp. The argument type can be
character, date, time, or timestamp.
If the argument is a character, its value must correctly represent a timestamp; that
timestamp is the result.
If the argument is a date, the value of the result is the timestamp, with the date
component equal to the argument and the time component equal to midnight.
If the argument is a time, the value of the result is the timestamp, with the date
component equal to the current date, and the time component equal to the argument.
If the argument is a timestamp, its value is returned.
The LOG function returns the natural logarithm of the input value.
This function returns double precision numbers with three decimal places.
The SQRT function returns the square root of the input value.
The COUNTBY function produces a column whose values are incremented row by row by a
specified amount.
where:
character
Is the input value.
This function returns an alphanumeric value.
The IF function tests a condition and returns a value based on whether the condition is true
or false.
The LENGTH function returns the actual length in memory of a data item.
returns 4.
16 SQL Operators
The CASE operator allows a value to be computed depending on the values of expressions
or the truth or falsity of conditions.
The COALESCE operator can take 2 or more arguments. The first argument that is not NULL
is returned. If all arguments are NULL, NULL is returned.
The NULLIF operator returns NULL if its two arguments are equal. Otherwise, the first
argument is returned.
Index
A character functions (continued)
BITVAL 31, 32
ABS function 178, 232 BYTVAL 32
CHKFMT 33
alphanumeric strings 164 CTRAN 34, 35
ARGLEN function 28 CTRFLD 36
DCTRAN 74
ASIS function 29 DSTRIP 76, 77
ATODBL function 164 EDIT 37, 38
GETTOK 38, 39
AYM function 129 LCWORD 40, 41
AYMD function 130 LCWORD2 41
LCWORD3 42
LJUST 43
B LOCASE 43, 44
OVRLAY 44, 45
bit strings 31, 32 PARAG 46, 47
POSIT 48, 49
BITSON function 30, 31 RJUST 50, 51
BITVAL function 31, 32 SOUNDEX 51, 52
SPELLNM 52, 53
BUSDAYS parameter 96 SQL 199
business days 95, 96 SQUEEZ 54
BUSDAYS parameter 96 STRIP 55, 57
BYTVAL function 32 SUBSTR 57, 58, 59, 67
TRIM 59, 60
TRIMV 69
C UPCASE 60, 61
variable length 63
CASE operator 242 character strings 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 43, 44, 46, 48, 50, 51, 52,
CAST function 224
54, 57, 59, 60, 67
CHAR function 225 bits 30, 31
centering 36
CHAR_LENGTH function 200
comparing 51
character functions converting case 43, 60
ARGLEN 28 Dialogue Manager 29
ASIS 29 dividing 46
BITSON 30, 31 extracting characters 37
G I
GETTOK function 38, 39 IF function 237
GETUSER function 195 IMOD function 180, 181
GREGDT function 138, 139 INT function 183, 228
INTEGER function 228
H international date formats 107
O
N
OVRLAY function 44, 45
NORMSDST function 185, 187
NORMSINV function 185, 187, 188
P
NULLIF operator 245
numbers 178, 180, 181, 183, 184, 185, 186, packed numbers, writing to an output file 175
187, 188, 189, 190 PARAG function 46, 47
absolute value 178
calculating remainders 180 PATTERN function 47
V X
VALUE function 239 XTPACK function 175
values 88, 90
decoding 88
verifying 90 Y
variable length character functions 63 YEAR function 221
YM function 139, 140
W YMD function 134, 135
WEEKFIRST parameter 144
Reader Comments
Name:
Company:
Address:
Telephone: Date:
Email:
Comments:
Information Builders, Two Penn Plaza, New York, NY 10121-2898 (212) 736-4433
Functions Reference DN3501991.0511
Version 7 Release 7.03
Creating
Functions Reports With
Reference
WebFOCUS Language
Version 7 Release 7.03
Version 7 Release 6
Information Builders
Printed on recycled paper in the U.S.A.
Two Penn Plaza
New York, NY 10121-2898