Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help writing a query to sum Minutes

Status
Not open for further replies.

JVZ

Programmer
Sep 3, 2002
205
CA
Hello all,

I need help writing a query that will sum the Minutes.

For format of the time field is: MMMMSST (the field will always contain 7 characters).

Where M = min, S = Sec, and T = tenth of a sec.

Any suggestion?

Thanks

 
Is this what you're looking for?

SELECT Sum(Left(TimeField,4)) FROM TimeTable

--Angel [rainbow]
-----------------------------------
Every time I lose my mind, I wonder
if it's really worth finding.
 
Thanks for the reply. That is sort of what I'm looking for, however I need to also account for the seconds when summing.
 
Try this ...

Code:
SELECT 
  Sum(convert(int,Left(TimeField,4))) 
  + (Sum(convert(int,(Substring(Timefield, 5, 2)))) / 60) 
  + (Sum(convert(int,(Right(TimeField, 1)))) / 600) 
FROM TimeTable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top