Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Getting AVG as a decimal


Message #1 by "Richard Boarman" <asp@a...> on Wed, 26 Sep 2001 14:33:10
I have the following Select statement that gets the average time between two dates 

for a selected number of records. This always returns a whole number. Is there a 

way to have it return a numeric value with one digit right of the decimal (i.e. 16.7 

instead of 17)



SQL ="SELECT AVG (DateDiff(dd,requestdate, completedate)) AS 

AverageNumberofDays FROM Item WHERE ApprID = '"& rsAppr("apprID") &"';"

	Set rsDays = Database.ExecuteQuery(SQL)

Message #2 by "phil griffiths" <pgtips@m...> on Thu, 27 Sep 2001 12:05:28
Try a CAST before taking the average, example:

SELECT AVG (CAST(DateDiff(dd,requestdate, completedate) AS float)) AS 

AverageNumberofDays FROM Item WHERE ApprID = '"& rsAppr("apprID") &"';"



Phil

> I have the following Select statement that gets the average time between 

two dates 

> for a selected number of records. This always returns a whole number. Is 

there a 

> way to have it return a numeric value with one digit right of the 

decimal (i.e. 16.7 

> instead of 17)

> 

> SQL ="SELECT AVG (DateDiff(dd,requestdate, completedate)) AS 

> AverageNumberofDays FROM Item WHERE ApprID = '"& rsAppr("apprID") &"';"

> 	Set rsDays = Database.ExecuteQuery(SQL)


  Return to Index