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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Viewing records based on date being in future

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
GB
Hi,

I am trying to look up records where a value HolidayDate is in the future but not in the same month:

SELECT *
FROM StaffHolidays
WHERE UserID=124 And HolidayDate>=#10/25/2006# And DatePart('yyyy',HolidayDate)<>DatePart('yyyy',2006/10/25) And DatePart('m',HolidayDate)<>DatePart('m',2006/10/25);

However it is returning a record where HolidayDate is 26/10/2006.

Any ideas why?

Thanks very much

Ed
 
WHERE UserID=124 And HolidayDate>=#2006-10-25# And Format(HolidayDate,'yyyymm')<>'200610'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I was just typing the same thing, but PH beat me to the punch!

In addition, if this is to be used in the future you should make all of your criteria based off of Date() rather than a hard coded date.

Hope it helps,

Alex

Professor: But what about your superintelligence?
Gunther: When I had that there was too much pressure to use it. All I want out of life is to be a monkey of moderate intelligence who wears a suit. That's why I've decided to transfer to Business School.
Professor: NOOOOOOOOOOOO.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top