How can i make calculation ?

mohanarajmohanaraj 600001
edited 9:21AM in FastReport .NET
Dear all,

How can i make my won calculation for the summary band?

I having the field Duration this field having total duration of calls in seconds. Now i can able to total the duration column it returns total seconds but i want to display this field (Total seconds) in HH:MM:SS format. How it possible please advice.

Thanks in advance.

Comments

  • edited 9:21AM
    Hello,

    Sum your field using FastReport total, then convert the total value from seconds to hh:mm:ss format using a script function.
  • mohanarajmohanaraj 600001
    edited 9:21AM
    AlexTZ wrote: »
    Hello,

    Sum your field using FastReport total, then convert the total value from seconds to hh:mm:ss format using a script function.


    Dear Alex,

    I sum the field by adding New total to the data window and in the total popup window i select the duration field and save. Then i place this total field in the summary band and right click then i choose format (time to 13:30) and saved.

    Then i run the report the result displayed wrong.

    This is right way? Please advice about " format using a script function."
  • edited 9:21AM
    Since your sum is a number of seconds, you just can't format it using standard format means (you need DateTime value to do this). That's why you have to convert your value manually (either convert it to DateTime somehow, then format it using standard FastReport means; or use custom function that will extract hours, minutes and seconds from this value and output them in a report).
  • edited 9:21AM
    The elegant solution is to use TimeSpan. Put this in your Text object, and you get hh:mm:ss value.

    [TimeSpan.FromSeconds(your_seconds_value)]
  • mohanarajmohanaraj 600001
    edited 9:21AM
    AlexTZ wrote: »
    The elegant solution is to use TimeSpan. Put this in your Text object, and you get hh:mm:ss value.

    [TimeSpan.FromSeconds(your_seconds_value)]

    Dear Alex,

    Thanks Its work fine.
  • mohanarajmohanaraj 600001
    edited October 2009
    AlexTZ wrote: »
    The elegant solution is to use TimeSpan. Put this in your Text object, and you get hh:mm:ss value.

    [TimeSpan.FromSeconds(your_seconds_value)]

    Dear Alex,

    In the above line of code not working when i gave the second as 141700.
    It display wrongly as 1.15:21:40 instead of 39:21:40 please give suggestion.

    >
  • edited 9:21AM
    Write this in your report script:
      public class ReportScript
      {
        private string SecondsToHHmmss(int seconds)
        {
          int hours = seconds / 3600;
          seconds = seconds - (hours * 3600);
          int minutes = seconds / 60;
          seconds = seconds - (minutes * 60);
          return String.Format("{0:00}:{1:00}:{2:00}", hours, minutes, seconds);
        }
      }
    

    and use this function in your Text object:
    [SecondsToHHmmss(141700)]
  • mohanarajmohanaraj 600001
    edited 9:21AM
    Dear Alex,

    Thank you.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.