Skip to main content

MID

The MID function is used to extract a portion of a string, starting from a specified position and including a specified number of characters (or all remaining characters if no number is specified).

The MID function takes two or three parameters: value, which is the string to extract the portion from, start, which is the position to start from, and num, which is the number of characters to extract (num is optional).

If only two parameters are specified, the MID function returns all characters starting from the specified position to the end of the string.

Syntax

string MID(string value, int start, int num)
string MID(string value, int start)

Inputs

ObjectData TypeDescription
valueStringA string.
startIntegerA number identifying the start position in the string.
numIntegerThe number of letters to take from the start position.

Example

Extracting a Portion of a String with a Specified Length

Suppose you have a string "Hello, World!", and you want to extract the word "World" from it. You can use the MID function as shown below:

MID("Hello, World!", 8, 5)

In this example, the MID function is used to extract the portion of the string starting from position 8 (which is the first character of "World"), and then includes the next 5 characters.

Extracting a Portion of a String without a Specified Length

Suppose you have a string "Hello, World!", and you want to extract the word "World" from it without specifying the length. You can use the MID function as shown below:

MID("Hello, World!", 8)

In this example, the MID function is used to extract the portion of the string starting from position 8 (which is the first character of "World"), and including all remaining characters.

Extracting a Portion of a String from a Column in a Data Sync Project

Suppose you have a Data Sync project that has a column called ProductID. you know that your productID's always start with the same five digits and a "-" and you only want to return the digits after the first 5 e.g. "12345-abc345":

MID(ProductID, 7)

This will return everything after the "-" from the 7th position in the string, as the "-" is at the 6th position. Using the example above this will return "abc345". By not stating how many characters you wish to count it will return all characters to the end of the sequence.