Click to See Complete Forum and Search --> : Need Help with DateTime Query


dkirk
01-16-2008, 03:40 PM
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. 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?? Uisng todays date as an example (1/16/08), my initial attempt is below:


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!

chazzy
01-16-2008, 08:16 PM
it's going to really depend on your dbms, they all manage dates differently.