Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Comments
ZurdoDev 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

When you are trying to get sum of a TimeFormat, you should sum the minutes.
Try executing this query in your query window
SQL
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 
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900