Jump to content

Recommended Posts

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.