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()) +
Sent: Monday, May 06, 2002 2:20 PM
> 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
> l
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
>
&
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
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
exp
9 matches
Mail list logo