Returns a substring of string starting at the start character and counting length characters. Counting starts from 1 (not 0).
Always counts in the natural direction of the advertiser’s locale. For example, if the advertiser’s language is English, this function counts from left to right.
This function can be used only in inventory templates in manual campaigns. Templates in upgraded inventory management use a different set of functions.
Syntax
MID(string, start, length)
Specify the function name in upper case: MID
Parameters
- string: An inventory attribute such as
DESCRIPTION
, or a static string surrounded by quotes such as "Shoes".
Specify standard attributes in upper case; use the Search Ads 360 UI for guidance on specifying custom attributes. - start can be any of the following:
- A positive integer, such as 5.
- An expression or inventory function that returns a positive number.
- length can be any of the following:
- 0 (zero).
- A positive integer, such as 5.
- An expression or inventory function that returns a positive number.
Examples
-
MID(DESCRIPTION, 4, 8)
applies the function to the description as returned from the inventory feed. For example, if the description is "Hello World!", the function returns lo World. -
MID("Hello World!", 5, 0)
returns "" (empty string). -
MID("Hello World!", 0, 12)
is an error. Counting begins with 1, not zero. -
MID("every dog has its day", 1, -1)
is an error. Negative numbers are not valid.