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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Average time duration ? 1

Status
Not open for further replies.

redgate

Programmer
Oct 15, 2001
29
0
0
GB
Hi

As an input file I have a list of times(durations) in the format hh:mm:ss .

I created a table with a column of datetime and have written these in the format '1900/01/01 hh:mm:ss'.

I am trying to get an avearge of these durations.
I would also like to calculate the total in days, hours and minutes.

I suspect that maybe my column datatype is the incorrect choice.

Am I way off track ?
 
Does this help?

SELECT cast(avg(cast(duration as integer))as datetime) from myTable

-- Just trying to help... LOL [ponder]
 
Hi mwolf00

I tried your code but it returns '1900/01/01 00:00:00' .

I then tried simply

SELECT cast(duration as integer) from myTable

and my results where all zeroes.

Thanks for the reply.

Any other thoughts ?



 
OOOHHHH! Sorry....

SELECT cast(avg(cast(duration as float))as datetime) from myTable -- Just trying to help... LOL [ponder]
 
Hi mwolf00

So far I have got this to work

DECLARE @NVAL DATETIME
DECLARE @DIFF INT

SET @DIFF = (SELECT AVG(DATEDIFF(S, '1900/01/01',DURATION)) FROM MYTABLE)
SET @NVAL = DATEADD(S, @DIFF,'1900/01/01')

SELECT @NVAL AS AVERAGETIME

but can't help thinking I am going in the wrong direction.
Will try your next suggestion.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top