Hi, You should use the DATEDIFF() and DATEPART function. It allows you to do milliseconds calculation :)
SELECT AVG(Value) FROM tblfoo Where fooTime Between ( DATEDIFF(mi, GETDATE()-X) AND DATEPART(mi, GETDATE()) ) >I have a SQL Server 2000 DB that has a table with 2 columns: fooTime and >Value. fooTime is a DateTime and populated using NOW(). This is >updated about every second, and the Value changes about .001 each >update, either up or down. > >I want to get the average of Value from X minutes ago until now. X will >change according to the whims of the user. > >I have tried > >Select AVG(Value) >FROM tblfoo >Where fooTime Between (minute, NOW - X) AND (minute,NOW) > >But the results don't seem to be right. If I calculate the average >manually, it does not match the query results. > >What am I doing wrong? --- You are currently subscribed to activeserverpages as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED]
