locked
RDLC time format RRS feed

  • Question

  • User1437614245 posted

    Hello,

    I got very annoying problem. I'm trying to format time in RDLC. In the DataSet, the field is System.TimeSpan type. When I put it in my report, I get (as expected) time that looks like HH:mm:ss. I want to change it to HH.mm. I'm using formatting for that. Here's what I get:

    • if I use 't' > I get HH:mm:ss (should me HH:mm),
    • if I use 'T' > I get HH:mm:ss,
    • if I use any other format (f. e. HH:mm, HH.mm) I get #Error.

    Any ideas why do I get #Error and how to set time format to HH.mm?

    Thursday, September 11, 2014 3:44 AM

Answers

  • User1437614245 posted

    After trying numerous of things I found a solution.

    First, I needed to use 'hh' instead of 'HH' to show hours.

    Second, I cannot use simple symbols ':' or '.'. I need to use '\:' or '\.'.

    So, to get the string I wanted (HH.mm), I need to use format hh\.mm.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, September 20, 2014 12:42 AM

All replies

  • User-734925760 posted

    Hi,

    So far as I know, if you want to format the DataTime, please refer to the code below:

    = FORMAT(Globals!ExecutionTime, "hh:mm")
    

    Also, you can convert the DateTime to String, please refer to the code below:

    string printableString;
    DateTime dateValue;
    dateValue="22-08-2010 14:57:33";
     
        printableString = dateValue.ToString("hh:mm");
    

    Hope it's useful for you.

    Best Regards,

    Michelle Ge

    Thursday, September 11, 2014 10:13 PM
  • User1437614245 posted

    Thanks for your response.

    I tried adding

    = FORMAT(Fields!start_time.Value, "hh.mm")

     but with no luck. Still getting #Error. And my data type is TimeSpan.

    Friday, September 12, 2014 4:07 AM
  • User1437614245 posted

    After trying numerous of things I found a solution.

    First, I needed to use 'hh' instead of 'HH' to show hours.

    Second, I cannot use simple symbols ':' or '.'. I need to use '\:' or '\.'.

    So, to get the string I wanted (HH.mm), I need to use format hh\.mm.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, September 20, 2014 12:42 AM