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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With