locked
printing a 'backspace' in ssrs expression RRS feed

  • Question

  • User-314657242 posted

    Hello All,

    I need to know who to print a 'backspace' in SSRS expressions. What I want is that there's a string like 'Sun,Mon,Tue,Wed,Thu,Fri,Sat,' and i want to remove the last comma. So, I need to print a backspace at the end of the stirng. I've tried with chr(8), but this doesnt help.

    Sun,Mon,Tue,Wed,Thu,Fri,Sat,[] - this is what I got when i added chr(8).

    Please let me know how to do this.


    Thanks in advance

    Thursday, December 6, 2012 4:55 AM

All replies

  • User-1185172246 posted

    You cannot use such approach! What you need to use is the Substring method of string class. To get the current day name you could use this in an expression: =DateTime.DayOfWeek.ToString().Substring(0,3)

    Thursday, December 6, 2012 6:20 AM
  • User-314657242 posted

    okay, I have a bit of a 'length' expression to get this done, due to the complexity of the data to be displayed:

    =iif(Fields!Frequency.Value = "Daily", 
    	Fields!Frequency.Value, 
    	iif(Fields!Frequency.Value = "One Time", 
    		Fields!Frequency.Value & ":" & FORMATDATETIME(Fields!DateTime.Value, 2), 
    			iif(Fields!Frequency.Value = "Monthly", 
    				Fields!Frequency.Value & ": Day " & DATEPART("d", Fields!DateTime.Value),""))) &
    				iif(Fields!Frequency.Value = "Weekly", Fields!Frequency.Value & ": Every " & Fields!WeekNo.Value & " weeks " & vbcrlf & (iif(Fields!Sunday.Value = "true", "Sun," ,"") & iif(Fields!Monday.Value = "true", "Mon,", "") & iif(Fields!Tuesday.Value = "true", "Tue,","") & iif(Fields!Wednesday.Value = "true", "Wed,","") & iif(Fields!Thursday.Value = "true", "Thu,","")  & iif(Fields!Friday.Value = "true", "Fri,","") & iif(Fields!Saturday.Value = "true", "Sat,","")).substring(0, LEN(iif(Fields!Sunday.Value = "true", "Sun," ,"") & iif(Fields!Monday.Value = "true", "Mon,", "") & iif(Fields!Tuesday.Value = "true", "Tue,","") & iif(Fields!Wednesday.Value = "true", "Wed,","") & iif(Fields!Thursday.Value = "true", "Thu,","")  & iif(Fields!Friday.Value = "true", "Fri,","") & iif(Fields!Saturday.Value = "true", "Sat,",""))-1),"")

    It gives me the error (#Error) when the data falls under the first 3 conditions (Daily, One time and Monthly). I also noticed the error comes due to -1 in the LEN function. However, for weekly option I get the last comma removed value properly

    Thursday, December 6, 2012 7:01 AM