Free Support Forum - aspose.com

Problems with sum of hours

Hi,

I’m trying to sum hours in excel in a cumulative way, that is, if I add 23:50 and 1:20 the result must be 25:10 and not 1:10. I use the formula SUM and the cell format Cool:mm to do this. The problem is, since aspose put values of datatime type and excel always set a date ahead the time, format Cool:mm sum also the hours related to the date that appears in the cell.

I’ve tried to solve this problem changing the cell format and using the h:mm format but, although this format allows me to set only a time value -without date- in a cell, the sum of times is not cumulative and the result of add, for example, 23:50 and 1:20 is 1:10 and not 25:10 as I want.

Could someone give me a solution for this problem?

<span style=“font-size: 12pt; font-family: “Times New Roman”;” lang=“ES-TRAD”>My version of aspose is the 3.1.1.5, anyway, I’ve downloaded and tested 3.2.0.0 version of Aspose and the problem is not solve yet. I have MS Excel 2003 Professional Edition.

Thanks in advance.


This Topic is created by shakeel.faiz using the Email to Topic plugin.

dmarin wrote:
Hi,

I'm trying to sum hours in excel in a cumulative way, that is, if I add 23:50 and 1:20 the result must be 25:10 and not 1:10. I use the formula SUM and the cell format Cool:mm to do this. The problem is, since aspose put values of datatime type and excel always set a date ahead the time, format Cool:mm sum also the hours related to the date that appears in the cell.

I've tried to solve this problem changing the cell format and using the h:mm format but, although this format allows me to set only a time value -without date- in a cell, the sum of times is not cumulative and the result of add, for example, 23:50 and 1:20 is 1:10 and not 25:10 as I want.

Could someone give me a solution for this problem?

My version of aspose is the 3.1.1.5, anyway, I've downloaded and tested 3.2.0.0 version of Aspose and the problem is not solve yet. I have MS Excel 2003 Professional Edition.

Thanks in advance.

Sorry,

In my last post, when I talked about the cell format I use, I wanted to say this format [.h]:mm, and, evidently, not this, Cool:mm.

Thanks.

In MS Excel, if you input 23:50 in A1, 1:20 in A2, and “=A1+A2” in A3, the result in A3 is 1:10. So it’s not a bug but a routine in MS Excel.

In you case, 23:50 is DateTime and 1:20 is TimeSpan. So I think it’s better to use C# code to calculate it.