MID

Returns a substring of specified length from the string passed to the function, starting with the specified index. The function uses zero-based indexing.

Syntax

= MID(str, startIndex, length)

Parameters

str

A string that contains the characters which have to be extracted. The value can be specified as a decimal value (e.g., 37.48), as a string (“Word”), as the value of a variable (e.g, FirstName) or as a date ("02/19/2009”)

startIndex

A positive integer which specifies the start position from which characters have to be extracted.

length

A non negative integer which specifies the number of characters to be extracted.

Return Type

String

In the case of an error, the function displays an error message: “MID(str, startIndex, length): Error message”

The function can be used in combination with other functions.

Examples

Example

Returns

= MID(“TEST”, 2, 2)

“ES”

= MID(“Iron Speed Designer”, 5, 5)

“Speed”

= MID(“$1234”, 0, 1)

“$" which is the currency sign

= Mid(FirstName, 0, 1)

The first character of the first name.

= UPPER(MID(“Iron Speed Designer”, 5, 5))

The upper case version of the extracted string.

= CONCATENATE(“Iron”, MID(“Iron Speed Designer”, 5, 5))

A concatenated version of the extracted string with the passed string.