Click here to Skip to main content
11,928,985 members (54,489 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# VB 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 6:07am
ryanb31 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.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