SSRS Time HH:MM:SS Sum - reporting-services

Can someone please help me with the following:
I am trying to use an expression to calculate the sum of four different times.
Queue Time, Ring Time, Hold Time, Talk Time
These times are coming from a stored procedure as a single digit (5 seconds is simply value '5')
I have used the following expression to convert this to HH:MM:SS (00:00:05)
=Format(DateAdd("s", SUM(Fields!quetime.Value), "00:00:00"), "HH:mm:ss")
Can someone please point me in the right direction to add these four times together and keep the HH:MM:SS format?
I have tried the following but I get #Error:
=Sum(Format(DateAdd("s", SUM(Fields!quetime.Value), "00:00:00"), "HH:mm:ss")
+ Format(DateAdd("s", SUM(Fields!ringtime.Value), "00:00:00"), "HH:mm:ss")
+ Format(DateAdd("s", SUM(Fields!holdtime.Value), "00:00:00"), "HH:mm:ss")
+ Format(DateAdd("s", SUM(Fields!TalkTime.Value), "00:00:00"), "HH:mm:ss"))
(Broken up for on separate lines here for readability)
I would like to do this within SSRS and not in SQL.
Thanks in advance,
Greg

I figured it out!
The following did the trick:
=Format(DateAdd("s", SUM(Fields!quetime.Value + Fields!ringtime.Value + Fields!holdtime.Value + Fields!TalkTime.Value), "00:00:00"), "HH:mm:ss")

Related

SSRS2016 Convert seconds to hh:mm:ss format

I have a table with a column, Duration that has value in seconds.
In Visual Studio / SSRS 2016 I want to display it in HH:MM:SS format.
I have tried to use the following expressions
=Format(DateAdd("s", Fields!Duration.Value, "00:00:00"), "HH:mm:ss")
But it didn't seem to work correctly, for example, 1800s will be displayed as 01:38:00
Can anybody see the problem?
Thanks!
To convert a number of seconds to time format use the TimeSerial function:
=Format(TimeSerial(0,0,Fields!Duration.Value),"HH:mm:ss")
The problem with your way might be that it is not implicitly converting from the text string to time format as you expect, so the following may also work:
=Format(DateAdd("s", Fields!Duration.Value, TimeValue("00:00:00")), "HH:mm:ss")

SSRS Format calculated timespan in dd:hh:mm:ss

I have a report and one of the fields calculates a timespan in an expression e.g
=Fields!Date1.Value-Fields!Date2.Value
I would like to display in the format dd:hh:mm:ss so days,hours,minutes and seconds. If i just leave the expression it sort of works but i get milliseconds which i don't want and if there are no days then that value disappears.
I've seen lots of examples using formatting to get HH:mm:ss but not on how to do the days.
Try:
=Floor(DateDiff("s",Fields!Date1.Value,Fields!Date2.Value) / 86400) & ":" &
Format(DateAdd("s", Fields!Date1.Value-Fields!Date2.Value, "00:00:00"), "HH:mm:ss")
It will give you dd:HH:mm:ss format. Note Date1 must be greater than Date2.
Based on #alejandro's answer I ended up with
=Format(Floor(DateDiff("s",Fields!Date1.Value,Fields!Date2.Value)/86400),"00")
& ":" & Format(DateAdd("s", (Fields!Date2.Value-Fields!Date1.Value).TotalSeconds,
"00:00:00"), "HH:mm:ss")
just doing the straight subtraction didn't seem to work.

How do I Sum Hour and Minutes SSRS 2012?

I have a column in my report that contains text values like:
01:30
00:45
02:15
And so on. How do I get a total like this?
04:30
As a total time spent. I am trying this Expression -
= FLOOR(Sum(Cint(Left(Fields!est_pack_time.Value,2)), "DataSet1") ) & ":" & RIGHT("0" & (Sum(Cint(Right(Fields!est_pack_time.Value,2)), "DataSet1") MOD 60), 2)
This gives me something close but it is still not right. I am summing the total time across the entire dataset.
You were on the right track - your expression is just not carrying the extra hours from summing up the minutes into the total hour time.
The updated expression will be something like this:
=Right("0" & Sum(CInt(Left(Fields!est_pack_time.Value,2)), "DataSet1")
+ Floor(Sum(CInt(Right(Fields!est_pack_time.Value,2)), "DataSet1") / 60),2)
& ":" & Sum(CInt(Right(Fields!est_pack_time.Value,2)), "DataSet1") Mod 60
This is taking the total from the hours, adding the overflow from the total minutes, then concatenating the minutes to this string. It's also padding the hours with a leading zero to make sure the string is always 5 characters.
Works for me in a quick test:
Finally, it probably goes without saying that if at all possible it's best to move away from storing time durations in a text format, but of course that might not be possible in your case.
=split(TimeSpan.FromTicks(Sum(Fields!TotalHours.Value)).TotalHours,".").GetValue(0) &":"
& Format(TimeSpan.FromTicks(Sum(Fields!TotalHours.Value)).TotalMinutes mod 60,"00")
=replace( left(TimeSpan.FromTicks(Sum(Fields!TotalHours.Value)).TotalHours,3)&":"
& right(TimeSpan.FromTicks(Sum(Fields!TotalHours.Value)).TotalHours,3)*60,".","")

How to Display beyond 24 hrs in SSRS 2008 in HH:MM:SS format

I have a report in SSRS 2008 that pulls data from a table with a column, TotalTime that is an Integer value in seconds.
To display is as time I use this in the expression:
=Format(DateAdd("s", Fields!TotalTime.Value, "00:00:00"), "HH:mm:ss")
(got that from here: Display Seconds Count in HH:MM:SS format in SSRS 2008)
Now, when the value goes beyond 24 hrs it does kind of a "module" value. I mean this: if the value would be 29 hrs, instead of displaying 29:00:00 it will display 05:00:00. If the value if 51 hrs, it will display 03:00:00 (takes out 48 hrs).
How do I solve this?
Thanks!
There are 86,400 seconds in a day. So just use days if the seconds are greater than that:
=IIF(Fields!TotalTime.Value < 86400,
Format(DateAdd("s", Fields!TotalTime.Value, "00:00:00"), "HH:mm:ss"),
Floor(Fields!TotalTime.Value / 86400) & " days, " & Format(DateAdd("s", Fields!TotalTime.Value, "00:00:00"), "HH:mm:ss")
For HH:mm:ss format you can use this:
=Floor(Fields!TotalTime.Value / 3600) &":"& Format(DateAdd("s", Fields!TotalTime.Value, "00:00"), "mm:ss")
In this case, for example 90000sec will be displayed as: 25:00:00
For DD:HH:mm:ss format use this:
Floor(Fields!TotalTime.Value / 86400) &":"& Format(DateAdd("s", Fields!TotalTime.Value, "00:00:00"), "HH:mm:ss")
90000sec will be shown as: 1:01:00:00
You really need to use the hour based solution, the day based one can potentially get you into trouble with Daylight Savings Time change overs.
=Floor(Fields!TotalTime.Value / 3600) &":"& Format(DateAdd("s", Fields!TotalTime.Value, "00:00"), "mm:ss")

Display Seconds Count in HH:MM:SS format in SSRS 2008

I have a table with a column, TotalTime that is an Integer value in seconds.
In Visual Studio / SSRS 2008 I want to display it in HH:MM:SS format.
Thanks!
Just use an expression that adds that number of seconds to a zero time value
=Format(DateAdd("s", Fields!TotalTime.Value, "00:00:00"), "HH:mm:ss")
If it is larger than 24 hours, then you can use the following formula that adds the days portion:
=IIF(Fields!TotalTime.Value < 86400,
Format(DateAdd("s", Fields!TotalTime.Value, "00:00:00"), "HH:mm:ss"),
Floor(Fields!TotalTime.Value / 86400) & " days, " & Format(DateAdd("s", Fields!TotalTime.Value, "00:00:00"), "HH:mm:ss"))
For HH:mm:ss format you can use this:
=Floor(Fields!TotalTime.Value / 3600) &":"& Format(DateAdd("s", Fields!TotalTime.Value, "00:00"), "mm:ss")
In this case, for example 90000sec will be displayed as: 25:00:00
For DD:HH:mm:ss format use this:
Floor(Fields!TotalTime.Value / 86400) &":"& Format(DateAdd("s", Fields!TotalTime.Value, "00:00:00"), "HH:mm:ss")
90000sec will be shown as: 1:01:00:00