We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Sum of Time (Hours & Minutes)

Can you get the sum of time (hours & minutes) in a summary row? 
Time is a column in my grid.

13 Replies

HJ Hariharan J V Syncfusion Team May 6, 2013 05:42 AM UTC

Hi Tine Devolder,

Thanks for using Syncfusion Products.

Your requirement can be achieved by using the Custom type Summary Rows in GridGroupingControl. We have prepared simple sample to meet your requirements and the same can downloaded from the below link.

Sample:
Summary_Time.zip

Please try the above sample and if it does not meets your requirement, could you please provide more information on this so that we can provide a better solution quickly?.

Please let us know if you have any other concerns.

 

Regards,

Hariharan J.V.

 

 

 



TD Tine Devolder May 6, 2013 09:51 AM UTC

What about timespan?


TD Tine Devolder May 6, 2013 09:57 AM UTC

It doesn't get the sum of time 
  • min = 0
  • hour = 0


TD Tine Devolder May 6, 2013 10:04 AM UTC

It's okay. I have make a error


TD Tine Devolder May 6, 2013 12:05 PM UTC

Can you put the hours and minutes together?? 


HJ Hariharan J V Syncfusion Team May 7, 2013 10:38 AM UTC

Hi Tine Devolder,

Thanks for your update.

We glad to let you know that we have achieved your requirement. We have modified sample which was provided earlier and the same can be downloaded from the below link.

Sample: Summary_Time.zip

In the above sample we have displayed total time(hours + minutes) in a single summary row. Please refer the below code snippets.

[Default.aspx.cs]

public static ISummary TimeSummary(SummaryDescriptor sd, Record record)

        {

            if (record == null)

                t1 = Convert.ToDateTime("0:0:0");

                object obj = sd.GetValue(record);

            if (record != null)

            {

                t1 = t1.AddHours(Convert.ToInt32(Convert.ToDateTime(record.GetValue("Date")).Hour));

                t1 = t1.AddMinutes(Convert.ToInt32(Convert.ToDateTime(record.GetValue("Date")).Minute));

                str = t1.ToString("HH mm");

            }

            return (obj == null || obj is DBNull) ? Empty : new TotalSummary(str);

        }

 

Please let us know if you have any other concerns.

 

Regards,

Hariharan J.V.



TD Tine Devolder May 8, 2013 06:08 AM UTC

Thanks


TD Tine Devolder May 8, 2013 08:30 AM UTC

How about more then one column not only "Date"

t1 = t1.AddHours(Convert.ToInt32(Convert.ToDateTime(record.GetValue("Date")).Hour));
                t1 = t1.AddMinutes(Convert.ToInt32(Convert.ToDateTime(record.GetValue("Date")).Minute));


TD Tine Devolder May 8, 2013 09:09 AM UTC

I have a problem with your sample,
when I run the code it must be 42h but it is 18h


Summary_Time_Tine_555c50d8.rar


TD Tine Devolder May 13, 2013 12:27 PM UTC

?


HJ Hariharan J V Syncfusion Team May 14, 2013 12:53 PM UTC

Hi Tine Devolder,

Thanks for your update.

Query 1#: “How about more then one column not only "Date"”

Currently we are working on this query and this query forwarded to our development team. We will update you in two business days(May 16,2013)

 

Query 2#: “I have a problem with your sample, when I run the code it must be 42h but it is 18h”

We have modified the above given sample to meet your requirements. Please refer the below code snippets.

[Default.aspx.cs]

public static ISummary TimeSummary(SummaryDescriptor sd, Record record)

        {

            if (record == null)

            {

                i = 0;

                t1 = Convert.ToDateTime("0:0:0");

            }

            object obj = sd.GetValue(record);

            if (record != null)

            {

                if ((t1.Hour + Convert.ToInt32(Convert.ToDateTime(record.GetValue("Date")).Hour)) >= 24)

                {

                    i++;

                }

                t1 = t1.AddHours(Convert.ToInt32(Convert.ToDateTime(record.GetValue("Date")).Hour));

                if (((t1.Minute + Convert.ToInt32(Convert.ToDateTime(record.GetValue("Date")).Minute)) >= 60) && t1.Hour == 23)

                {

                    i++;

                }

                t1 = t1.AddMinutes(Convert.ToInt32(Convert.ToDateTime(record.GetValue("Date")).Minute));

                str = t1.ToString("HH:mm");

                if (i != 0)

                {

                    hh = Convert.ToDateTime(str).Hour;

                    mm = Convert.ToDateTime(str).Minute;

                    hh = hh + i * 24;

                    str = hh.ToString() + ":" + mm.ToString();

                }

            }

 

            return (obj == null || obj is DBNull) ? Empty : new TotalSummary(str);

        }

 

 

And the modified sample can be downloaded from the below link.

Sample: Summary_modified.zip

Please let us know if you have any other concerns.

 

Regards,

Hariharan J.V.

 



AL ALDO replied to Tine Devolder March 27, 2018 06:42 PM UTC

Can you put the hours and minutes together?? 

How many controls in  Essential Studio 



IR Isuriya Rajan Syncfusion Team March 28, 2018 07:02 AM UTC

Hi Tine Devolder, 

If you are looking for the ASP.NET MVC controls, please refer the below online sample and documentation link for our latest Essential ASP.NET MVC controls which are created over our next generation JavaScript controls. 



Please get back to us if you need further assiatance. 

Regards, 
Isuriya R 


Loader.
Up arrow icon