Click here to Skip to main content
11,789,706 members (63,150 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL .NET SQL-Server , +
I am creating a report and have a field in my database called "Duration" which is represented in time format. I am trying to calculate the total duration by adding the durations together using "[Sum(Duration)]". I keep however getting "#ERROR" when I do this.

If anyone could help me out I would be very grateful!
Posted 11-Jul-13 5:07am
ryanb31 at 11-Jul-13 13:05pm
You need to click on Improve question and post the relevant code so we can see what you have so far.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

When you are trying to get sum of a TimeFormat, you should sum the minutes.
Try executing this query in your query window
Declare @TempTable Table(TimeValue VarChar(20))

Insert Into @TempTable Values('12:00 PM')
Insert Into @TempTable Values('1:00 PM')
Insert Into @TempTable Values('10:00 AM')

Select Sum(DateDiff(Minute, 0, TimeValue)) As TotalDuration
       From   @TempTable 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 999
1 Maciej Los 765
2 KrunalRohit 686
3 CPallini 606
4 Richard MacCutchan 430

Advertise | Privacy | Mobile
Web02 | 2.8.1509028.1 | Last Updated 11 Jul 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100