I'm sure you meant to say

Select Avg(Value)
>From tblfoo
Where fooTime Between DateAdd(mi, -X, GetDate()) and GetDate()

HTH,
Tore.

PS: Mark, what do you mean by "...rile up Tore"?  :->


-----Original Message-----
From: Opec Kemp [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 29, 2002 8:01 PM
To: ActiveServerPages
Subject: RE: Date Difference for Minutes?


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.unsub%%

---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to