This is a discussion on Re: Limiting precision when using a formula for field within the SQL Server forums, part of the Microsoft SQL Server category; --> You can cast to the appropriate decimal scale: Use this as your formula: cast( (datediff(day,[Hire Date], (convert(datetime,convert(varchar,getdate(),1),1)) ) / ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| You can cast to the appropriate decimal scale: Use this as your formula: cast( (datediff(day,[Hire Date], (convert(datetime,convert(varchar,getdate(),1),1)) ) / 365.0) as decimal(6,2)) (Also, using 365.24 will be a bit closer to correct if this is intended to calculate a number of years.) Steve Kass Drew University papernate wrote: >I'm creating a field to keep track of how long someone has worked here. >I only want to have a precision of 2, and currently have this formula >entered in for the field: > >(datediff(day,[Hire Date], >(convert(datetime,convert(varchar,getdate(),1),1) )) / 365.0) > > > >The "precision" property is greyed out on me, and I'm not being allowed >to select the data type I want. Any ideas? > >-- >Posted via http://dbforums.com > > |