DateAdd() in WHERE clause not working?

zkarj

Registered User.
Local time
Tomorrow, 11:42
Joined
Dec 9, 2004
Messages
15
This is driving me crazy! What am I missing?

Here's my query:

SELECT tblRelease.ID, tblRelease.Application, tblRelease.Date, DateAdd("d",tblRelease.DateVariance,tblRelease.Date) AS ToDate, tblRelease.Time, tblRelease.Description
FROM tblRelease
WHERE (DateAdd("d",tblRelease.DateVariance,tblRelease.Date)>=[Enter Effective Date])
ORDER BY tblRelease.Application, tblRelease.Date;

I've chopped out a few fields to make it a bit smaller and easier to read.

The problem is that whilst the DateAdd() in the SELECT clause produces exactly the date that I want, the DateAdd() in the WHERE clause does not seem to work. I always get all records no matter what date I enter for [Enter Effective Date]. If I change the WHERE clause to

WHERE (tblRelease.Date>=[Enter Effective Date])

then everything works perfectly and I get different numbers of records depending on the date I enter.

I am entering the date in the form 01/08/2005 and this works for the second variation just fine. It's dd/mm/yyyy in case that's important (my local default).

Anybody see my problem?
 
OK, I just stumbled across the answer.

WHERE (DateAdd("d",tblRelease.DateVariance,tblRelease.Date)>=DateValue([Enter Effective Date]))

The problem being that Access was trying to help me when it saw the simpler version by implicitly doing the DateValue() but couldn't cope with the expression.
 

Users who are viewing this thread

Back
Top Bottom