# Text.Substring(Integer [, Integer]) Method
> Version: _Available or changed with runtime version 1.0._
Retrieves a substring from this instance.
## Syntax
```al
Substring :=   Text.Substring(StartIndex: Integer [, Count: Integer])
```
> NOTE
> This method can be invoked without specifying the data type name.
## Parameters
Text
Type: text-data-type
An instance of the text-data-type data type.
StartIndex
Type: ../integer/integer-data-type
The one-based starting character position of a substring in this instance.
*[Optional] Count*
Type: ../integer/integer-data-type
The number of characters in the substring.
## Return Value
Substring
Type: text-data-type
The substring extracted from this instance.
## Remarks
Starting with Business Central application version 27.1, the platform supports a Count parameter that exceeds the length of the input text. In application version 27.0 and earlier, the following code raises a runtime error Index and length must refer to a location within the string. (Parameter 'length'):
```al
NewString := '12345'.Substring(1, 10);
```
In this example, the input text `'12345'` has a length of 5, but the Count value is 10, which exceeds the string length. If you're targeting application version 27.0 or earlier, use text-copystr-method instead of Substring.
## Related information
text-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-substring-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/text/text-substring-method/
