[AccessD] OT: SQL SERVER DATEDIFF - DECIMAL PRECISION

Stuart McLachlan stuart at lexacorp.com.pg
Wed May 26 05:03:38 CDT 2004


> 
> > I'm looking to calculate the number of days between two days.  I got it to
> run perfectly however I want to show one decimal precision.  The query
> results shows 1.0 when in fact it is really 1.33.
> >
> > StartDate and ClosedDate are data types.
> >
> > select
> > Avg(DATEDIFF(day, StartDate, ClosedDate)) AS TurnDays
> > from
> > tblPrCas
> >

Problem is Datediff returns an Integer so AVG also returns an 
Integer. You need to convert the Integer to a float before calcuating 
the average.

Try 

Avg(CAST(DATEDIFF(day, StartDate, ClosedDate),Float)) AS TurnDays

 
-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System 
Support.






More information about the AccessD mailing list