none
How to format a TimeSpan in Report Designer RRS feed

  • Question

  • I am creating a report in Visual Studio 2010 Report Designer using a DataTable as the data source. I am trying to format a field which is of type TimeSpan so that it displays in the format "h:mm" (no leading 0), but I can't find the right formatting function and/or format string. (Seems like everything I've seen assumes a DateTime or equivalent.) Can someone help?
    Tuesday, November 27, 2012 10:18 PM

Answers

  • Well, here's my hack if anyone else stumbles across this problem:

    =Int(Sum(Fields!RegularHours.Value) / 36e9) & ":" & Format((Sum(Fields!RegularHours.Value) Mod 36e9) / 6e8, "00")
    (I needed to use the ticks and convert those to hours/minutes.)
    • Marked as answer by cgtyoder Thursday, January 3, 2013 1:19 PM
    Thursday, January 3, 2013 1:18 PM

All replies

  • Any suggestions here? I'm really having a hard time finding a good answer.
    Monday, December 10, 2012 4:34 PM
  • Well, here's my hack if anyone else stumbles across this problem:

    =Int(Sum(Fields!RegularHours.Value) / 36e9) & ":" & Format((Sum(Fields!RegularHours.Value) Mod 36e9) / 6e8, "00")
    (I needed to use the ticks and convert those to hours/minutes.)
    • Marked as answer by cgtyoder Thursday, January 3, 2013 1:19 PM
    Thursday, January 3, 2013 1:18 PM
  • If you want Time part we can add Date and make it as date time and format it to take Time Part.

    Format(Today() + Fields!RegularHours.Value, "HH:mm")

    Monday, March 17, 2014 4:33 PM