Dina...  My guess would be that it's returning an integer and rounding it
up...  Try doing:
(datediff(mm, hire_date, getdate())) / 12

This should return a floating number.  Then floor it if you want it to
always round down as so:
Floor((datediff(mm, hire_date, getdate())) / 12)


-----Original Message-----
From: Dina Hess [mailto:[EMAIL PROTECTED]] 
Sent: Monday, May 06, 2002 1:17 PM
To: CF-Talk
Subject: Re: transact-sql datediff function


thanks for taking a look at it, margaret. but the whole idea is that i'm
trying to find the difference (in years) between the hire date and today's
date.

~ dina

----- Original Message -----
From: "Margaret Fisk" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Monday, May 06, 2002 2:56 PM
Subject: RE: transact-sql datediff function


> Just a guess, but in the datediff you are just extracting the
year. If you
> want to include the
> month in the calculation, you should probably get the month
part too.
>
> Margaret
>
> -----Original Message-----
> From: Dina Hess [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 06, 2002 11:20 AM
> To: CF-Talk
> Subject: OT: transact-sql datediff function
>
>
> hi all,
>
> i posted this on the sql list but got no response.
>
> i have a test table named employees with the following fields:
>
> fname varchar
> lname varchar
> hire_date datetime
>
> the record i'm querying contains 2001-05-11 00:00:00.000 in the 
> hire_date field. but this query returns 1 rather than the expected 0:
>
> select datediff(yy, hire_date, getdate()) as yearsdiff from employees 
> where fname = 'ann'
>
> this should give me the number of years between 5/11/2001 and today's 
> date of 5/6/2002, which should be 0 since it's not 5/11 yet. so why am 
> i getting 1???
>
> ~ dina
>
>
>


______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to