Re: MS SQL 2000

From: Hugo Kornelis <hugo_at_pe_NO_rFact.in_SPAM_fo>
Date: Tue, 18 Jan 2005 17:33:55 +0100
Message-ID: <0fequ0tqvts1jeeu2sc9rjg5ks1dvfl68h_at_4ax.com>


On 18 Jan 2005 06:40:50 -0800, Kirby wrote:

>Hugo,
>
>Thanks for your help on this. Could you tell me under what
>circumstances my current code won't work. I run both what you did and
>what I did and they return the same results. Will I run into problems
>at the end of the year?

Hi Kirby,

Did you run the code I posted as proof that your version won't work?

Here it is again, in case you can't find my previous message:

create table Test (JobDate datetime)
insert Test (JobDate) values ('20060101') select * from Test
WHERE (CONVERT(varchar(12), JobDate, 101) <= CONVERT(varchar(12), DATEADD(day, 14, GETDATE()), 101)) AND (JobDate > GETDATE())
go
drop table Test
go

The reason that this fails is that the date I inserted in the test table is from a different year than the current year (the year in getdate()). As soon as your tables holds values with a year different from the current year, your query will start returning wrong results.

Best, Hugo

-- 

(Remove _NO_ and _SPAM_ to get my e-mail address)
Received on Tue Jan 18 2005 - 17:33:55 CET

Original text of this message