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

Confusing SQL DateTime query

Status
Not open for further replies.

redgenie

Programmer
Aug 10, 2000
36
GB
I have the following table:

Table: CharacterAvailability

Character StartTime(Date/Time) FinishTime(Date/Time)
CharA 07/03/2007 00:01:00 07/03/2007 23:59:00
CharA 10/03/2007 00:01:00 10/03/2007 23:59:00
CharB 10/03/2007 00:01:00 10/03/2007 23:59:00
CharA 11/03/2007 00:01:00 11/03/2007 23:59:00


If I try to execute the following SQL query, I would expect it to return "CharA" yet it returns nothing.
select Character from CharacterAvailability where StartTime <= #07/03/2007 19:30:00# and FinishTime >= #07/03/2007 23:30:00#;

Can anyone spot anything I'm doing obviously wrong?
 
Use non ambiguous date:
WHERE StartTime <= #2007-03-07 19:30:00# AND FinishTime >= #2007-03-07 23:30:00#;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top