Search code examples
ssrs-2008-r2ssrs-expression

SSRS Expression BC30205 error


I'm trying to convert some nvarchar type numbers to time format in SSRS. I can't do this on SQL side unfortunately. When I try my usual SQL approach I'M getting errors. I think it's syntax related but still can't be sure.

For example, I'm trying to get a "345" value written as 5:45.

=SUM(Fields!Total.Value)/60 & ":" & SUM(Fields!Total.Value)Mod 60

Edit:

When I try another approach and write it like ;

=Cstr(SUM(Fields!Total.Value)/60) + ":" + Cstr(SUM(Fields!Total.Value)Mod 60)

I get "BC30198 ')' expected" error..


Solution

  • You need to have a space on either side of the Mod operator, unlike a * or / operator.

    A good general way of doing this would be to parse your string into seconds, minutes, and hours, then use the TimeSerial() Function to create a DateTime Value with that time and the date set to 1/1/0001. Then you can use formatting to display just the time. This allows much more power, such as displaying the time in different formats or adding hours to the time.