The following section describes the syntax and usage of the MID function in ActivityInfo.
Description
The MID function is used to return a specified number of characters from the *middle *of a string (or text value).
Usage
MID(string, numChars, startPosition)
+-----------------------+-----------------------+-----------------------+ |
Argument | Required | Description |
+=======================+=======================+=======================+ |
string
| Yes | The text value.
| +-----------------------+-----------------------+-----------------------+ |
numChars | Yes |
The number of | | | | characters you wish | | | |
to return from the | | | | text value. | | | | | | | | This must be a
| | | |
numeric value. |
+-----------------------+-----------------------+-----------------------+ |
startPosition |
Yes | The starting position | | | | of the text you wish | | |
| to extract. The start | | | | position is measured | |
| | from 0 (i.e. the | |
| | first character in a | | | | string is 0, the | | | | second 2, etc.) | | | |
| | | | This
must be a | | | | numeric value. |
+-----------------------+-----------------------+-----------------------+
Remarks
- The sub-string extracted from the middle of the text value, starting at startPosition, which has a length of numChars.
- NA if the string is empty, not a text value, or if the number of characters requested exceeds the length of the original text.
Example
We will be using the MID function to extract text from the middle of a text field.
We will be using one Text field:
- "Text Field" (with code "text")
Using this formula:
MID(text, 3, 2)
we will attempt to extract 3 characters from the middle of the field, after the 2nd character in the text.
The formula returns this result: