I have a string with 30 characters but i only need the 20 of them. How can i get the first 20?
I tried this substring(ltrim(rtrim(field_value)),20)
But didn't work. Any ideas?
I have a string with 30 characters but i only need the 20 of them. How can i get the first 20?
I tried this substring(ltrim(rtrim(field_value)),20)
But didn't work. Any ideas?
Edit:
In My SQL
, you could use LEFT
(or SUBSTRING
) to SELECT
certain number of characters from a string
. Since what you need is the first characters, I suggest to use LEFT
:
SELECT LEFT(field_value, 20) FROM MyTableName
Original:
(As the tag was originally C#
, the following solution below provides solution for C#
problem)
You should use Substring(0, 20)
. The first argument (0
) is the starting index, and the second argument (20
) is the length of the string
you want to take.
For example:
var str = "123456789012345678901234567890";
str = str.Substring(0, 20);
You can use SubString method to get first 20 characters out of your string.
Try this way:
str= str.Substring(0, 20);