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).
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)
Barcode, Labeling, Printing & Imaging tools for ASP.NET Developers
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
chathu03j
Member
70 Points
112 Posts
printing a 'backspace' in ssrs expression
Dec 06, 2012 08:55 AM|LINK
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
Chathu
Associate Software Engineer - Colombo
Neodynamic
Participant
1008 Points
289 Posts
Re: printing a 'backspace' in ssrs expression
Dec 06, 2012 10:20 AM|LINK
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)
chathu03j
Member
70 Points
112 Posts
Re: printing a 'backspace' in ssrs expression
Dec 06, 2012 11:01 AM|LINK
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
Chathu
Associate Software Engineer - Colombo