Reportviewer regex RRS feed

  • Question

  • Hi all, I am trying to use microsoft reportviewer in C# to generate reports. All is working good but the more detail I want to include in the project the more problems come to light :-(.


    All my code inferstructure is in place so I cannot change it without making alot of work for myself.

    So my question to you is this

    In my SQL database I have a nchar column that I use to store a timespan in minutes. My problem is that its a nchar column and also includes the word minutes. Can I get just the numbers and use timespan so I get true minutes/hours.


    At the moment the data looks like this "120 minutes" I would like to convert this to 2hr 00minutes in my report, can this be done

    • Moved by Martin_Xie Tuesday, November 1, 2011 10:22 AM Move to VS Report Controls Forum. (From:Visual C# Language)
    Thursday, October 27, 2011 1:08 PM

All replies

  • Split the string by whitespace, and then Use TimeSpan class to get values of time:

                string text = "120 minutes";
                string[] array = text.Split(' ');
                TimeSpan ts = new TimeSpan(0, int.Parse(array[0]), 0);
                string newText = String.Format("{0} hours and {1} minutes", ts.Hours, ts.Minutes);

    Thursday, October 27, 2011 1:25 PM
  • Hi Mitja,

    The sample you have provided is at code level right?, how would I implement this into reportviewer. Where would I place this code




    Thursday, October 27, 2011 1:37 PM