A left trim is not grabbing all the data.

  • Hello again,

    I am having another issue with displaying my data.

    Here is an entry example:

    1.234;0;0;0;0;0;0;0

    It is a varchar cell.

    I am trying to grab all the data up to the first ";".

    In this example, I would want to display "1.234".

    I used this code to get it:

    =Trim(Left(Fields!Pcs.Value, InStr(StrReverse(Fields!Pcs.Value), ";")-1))

    It pulls the number without the decimals.

    For instance, it is displaying the number 1 instead of 1.234.

    I attempted to change the Text Box Properties to display it as a number with 3 decimal places, but that doesn't work. I also tried to change it to a decimal number. Same problem.

    Any ideas as to how I can get the correct data?

    Sincerely,

    James L. Eichelberger

  • DECLARE @InputString VARCHAR(15) = '1.234;0;0;0;0;0;0;0';

    PRINT LEFT(@InputString,(CHARINDEX(';',@InputString,1)-1));

  • Why not use the Split function?

    😎

  • Why did you use StrReverse, that seems not necessary unnecessary.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • The StrReverse was the culprit.

    I thought I needed the StrReverse to get the correct data.

    Obviously not.

    Thank you.

  • jeichelber (6/3/2014)


    The StrReverse was the culprit.

    I thought I needed the StrReverse to get the correct data.

    Obviously not.

    Thank you.

    No problem, glad you got it working 😀

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply