SSRS2016 Convert seconds to hh:mm:ss format - reporting-services

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")

Related

SSRS - How to AVG then format a number

I'm trying to get the average handle time per call to display as HH:MM:SS.
What I can't seem to figure out is how to take the AVG(Field) and make it HH:MM:SS. I can either A) avg and get the a decimal number which represents seconds or format total seconds for all calls in HH:MM:SS. but can't seem to marry the two. I'm sure it's simple but can't find anything on here that works.
This was one of my attempts that didn't work. "=Format(Avg(Fields!AHT.Value), 'HH:MM:SS')"
Any help would be greatly appreciated!
You should be able to do something like ...
=DATEADD(DateInterval.Second, AVG(Fields!AHT.Value), Today())
then format this textbox as Time in the textbox properties, under 'Number' or use the format code T
This gives this result..
All the expression does is take Today() which is only the date (therefore the time is 00:00:00) and then add the average number of seconds to it. So the actual result is today's date plus the time we want. Then format the textbox as time only, to hide the date portion.

AM/PM showing as A3/P3 when trying to select substring of DateTime in SSRS?

I am trying to get just the AM/PM part from a DateTime column in SSRS. I have tried both =Right(Fields!Start_Time.Value,2) and =Format(Fields!Start_Time.Value,"tt") and both gives me A3s and P3s. I have also tried =IIF(DatePart("hour",Fields!Start_Time.Value) < 12, "AM", "PM") which just displayed the original DateTime, unformatted. What is causing this and how do I just get the AM/PM part?
Are you sure that your field is a DATE/TIME or does it just look like a Date/Time field?
The only thing I can think of is that your field isn't actually a date/time type but just looks like one.
Try using CDATE to convert the Start Time field to a Date/Time that can be Formatted.
=Format(CDATE(Fields!Start_Time.Value),"tt")
UPDATE:
After reviewing your comments, I think you are putting the formula in the FORMAT property and not in the Expression. The way the question was written, I assumed you were populating the text box's Expression with the data formatted using the FORMAT function. If set the text box to the Start Time field and want to format using the FORMAT property, you would just put the in the FORMAT (tt) and not use the FORMAT function.
Try: =IIF( Mid(Fields!Start_Time.Value,12,2) < 12 , "AM", "PM")

SSRS Convert Seconds to MM:SS Without Truncating

I am formatting average handle time as mm:ss but it seems to be truncating. I viewed the articles that came up under questions that may have your answer, none of them are working for my situation.
I am using Microsoft Visual Studio 2015, designing SSRS reports.
The calculation is currently using the format function.
The value displayed is 05:30. The actual value should be 05:31.
Numbers in the calculation:
2,354,739 EmailHandleTimeTotal
7,119 EmailsTotal
Value in seconds = 330.7682
Code:
=Format(DateAdd("s", Sum(Fields!ID_EmailHandleTimeTotal_.Value) / Sum(Fields!ID_EmailsTotal_.Value, 0), "00:00:00"), "mm:ss")
Looking for help displaying the result as 05:31 please.
Thank you
Just round the seconds, for example like this:
=Format(CDate("00:00:00").AddSeconds(Round(Sum(Fields!ID_EmailHandleTimeTotal_.Value) / Sum(Fields!ID_EmailsTotal_.Value))), "mm:ss")

2007-06-17 09:05:34.813 - date format needs conversion

Need this format: 2007-06-17 09:05:34.813 modified in MS Access to be like this:
mm/dd/yyy hh:nn:ss AM/PM
Tried this in my Access query:
"newdate": Format([newdate],"yyyy/mm/dd hh:nn:ss")
but it's not working.
Source format is not a date, so your formula doesn't work. You need to remove number after dot:
Format(Left([newdate],InStr(1,[newdate],".")-1),"yyyy/mm/dd hh:nn:ss AMPM")

dd/mm/yyyy date format in SSRS

i'm trying to specify dd/mm/yyyy dateformat for date/time parameter in SSRS 2008 R2.
My computers datetime format is mm-dd-yyyy.
My requirement is, i want to show date format at dd/mm/yyyy irrespective of the system/server date format.
I've already tried CDate(Format(Today,"dd/mm/yyyy")) which didn't work. one very strange thing i observed is, it shows dd/mm/yyyy format only for dates on or before 12-MM-yyyy, and 13 onwards it gives error: Conversion from string '25-04-2014' to type Date is not valid. (Possibly it is trying to map 25(daypart) with MM-dd-yyyy (month part)) which is out of range of total months i.e. 12)
my research on internet says it is a bug in BIDS 2008.
What do i do to display date as dd/mm/yyyy ??
I don't have enough reputation to comment, but I did notice that you failed to put "()" after "Today". If I'm not mistaken you must put Today() for that function to work. Also, you might want to try putting CDate Around the Today() function. You shouldn't need it, but it's worth a shot. Also, for some odd reason, in my experience, you must capitalize MM for format to work correctly.
Like #Aditaya said, it should be =format(Today(),"dd/MM/yyyy")
The expression I usually use is:
=FormatDateTime(Fields!Date.Value, DateFormat.ShortDate)
However, this may be region specific.
Rather than writing an expression to do the formatting, you can also use the Textbox Format Property. But first you need to make sure that the data is in a date format. So use the CDate function on your column like this:
=CDate(Fields!Date.Value)
Then in the textbox properties go to the Number tab. Select Date for the category. Then you can select whichever format you want or use a Custom format. This will change how the column displays when you run the report.