to summarize, the following transact-sql code is touted by "The
Guru's Guide to Transact-SQL" as the best solution to return only
those employees whose hire date anniversaries fall within the
next 30 days:
select fname, lname, hire_date from employees
where datediff (yy, hire_date, getdate()) +
I hate to say it but the function is working as designed. I ran into the
same issue when looking for the number of months between dates.
>From SQL Server's Books Online: The method of counting crossed boundaries
such as minutes, seconds, and milliseconds makes the result given by
DATEDIFF consis
ays), it works. Let me know if it works for you.
I'm leaving for the day, I'll check my mail in the morning.
Ryan
-Original Message-
From: Dina Hess [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 06, 2002 5:16 PM
To: CF-Talk
Subject: Re: transact-sql datediff function
well, h
ginal 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 a
work as expected:
select fname, lname, hire_date
from employees
where datediff (yy, hire_date, getdate()) + 30) > datediff (yy,
hire_date, getdate())
maybe i'm doing something stupid. does this code work for you?
~ dina
- Original Message -
From: "Ryan Pieszak" <[EMAI
: Monday, May 06, 2002 4: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: "
ROTECTED]>
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
>
&
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
Sub
8 matches
Mail list logo