Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query question Dates

Status
Not open for further replies.

djj55

Programmer
Feb 6, 2006
1,761
US
Hello, I have inherited a query (used in a macro) that a date column has the criteria of <>Date() Or <>Date()-1
To me this seams to need an AND not an OR.
Actually I say make it <Date()-1.

Any comments?
Thanks
djj
 
There is no date that could possibly equal both today and yesterday at the same time. So or is probably correct.
 
No matter what you compare it to,

X <> Date() Or X <> Date()-1

will always return TRUE. Seems like a pointless test.
 
My mistake. The AND does make more sense.
X <> Date() AND X <> Date()-1
or
not(x=date() or x = date()-1)
 
Not much in the macro makes sense. The person who programmed it does not now how to code efficiently or should I leave it at does not now how to code.

Thank you for your replies.
djj
 
Actually I say make it <Date()-1

That looks right to me, unless future dates are possible.
 
Depends what you really want.
<Date()-1
returns any date earlier than yesterday, but no future dates.

It looked to me like they wanted
not(x=date() or x = date()-1)
which will return any date that is not today's or yesterdays. This would include days in the future.
 
Thanks everyone. The date is when we got the data so if it is in the future there is a problem. The NOT is possibly what they were looking for, but did not add and I doubt he would know how to do the parenthesis around both criteria.

Thanks again,
djj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top