MID function

MID(Text, StartIndex, Length?) MID(Text; StartIndex; Length?)

Text

Text or { Text }

The text string containing a part to extract.

StartIndex

Number or { Number }

The position in the text string marking the start of the part to be returned. The first character has position 1.

Length

Number or { Number } (optional)

The number of characters to include. If omitted, the rest of the text string is returned, starting at the given start position.

Returns

Text or { Text }

The sought text from the given text string.

Returns text from any part of a text string, effectively returning a substring. MID("abcd", 2)MID("abcd"; 2) returns "bcd", the characters of "abcd" starting at position 2. MID("abcd", 2, 2)MID("abcd"; 2; 2) returns "bc", two characters from "abcd" starting at position 2.

Consider using the CHARAT function instead if you need to extract a single character.

Examples

MID("abcd", 1, 1)MID("abcd"; 1; 1)

Returns "a", the first character of "abcd".

MID("abcd", 1, 2)MID("abcd"; 1; 2)

Returns "ab", the first two characters of "abcd".

MID("abcd", 2, 2)MID("abcd"; 2; 2)

Returns "bc", two characters of "abcd" starting with "b".

MID(TextField1, 1, LEN(TextField1) / 2)MID(TextField1; 1; LEN(TextField1) / 2)

Returns the first half of the value of TextField1. LEN returns the length of a text string.

MID("abcd", 2)MID("abcd"; 2)

Returns "bcd", the characters of "abcd" starting at position 2.

MID("abcd", 2, 2)MID("abcd"; 2; 2)

Returns "bc", two characters from "abcd" starting at position 2.