dkirk Posted January 16, 2008 Share Posted January 16, 2008 Hey gang, I need a little help creating a Query. I have a table storing info about visitors to our company. The name of the table is "visitors" and it has an "arrivalDate" field and a "departureDate" field. Both of these fields are of DateTime data type and both fields are populated prior to the visitors arrival, neither field will accept a null value. I need to run a report each day to see which visitors are currently on site. I am by no means a SQL expert and I am drawing a blank on how to extract this info?? Entry Example: name: John Doe arrivalDate: 1/16/08 departureDate: 1/20/08 So every morning between 1/16/08 and 1/20/08 John Doe must show up on the report I was trying to do something like this with my code (using todays date): SELECT name FROM visitors WHERE ((MONTH(arrivalDate) = 1 AND DAY(arrivalDate) >= 15 AND YEAR(arrivalDate) = 2008) AND (MONTH(departureDate) ????? if I were to go this route, it is the second half of the query that I am having problems. Am I going about this all wrong? Please help! Link to comment https://forums.phpfreaks.com/topic/86366-need-help-with-datetime-query/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.