473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

compare date and compare availability

cassbiz
202 100+
What I would like to do is run two queries with a single output.

for example my first query is:
Expand|Select|Wrap|Line Numbers
  1. <?
  2. $query = "(SELECT spacenummer FROM res WHERE arrival BETWEEN '$var_from' AND '$var_to' OR departure BETWEEN '$var_from' and '$var_to';)";
  3. ?>
  4.  

and the second query is

Expand|Select|Wrap|Line Numbers
  1. $query1 = "(SELECT spacenummer FROM spaces;)";
  2.  
The table spaces lists all of the available spaces.
The table res lists all booked spaces and dates.

I would like to find out if in the given date range a space is available then to show it in an output and/or give either a yes or no.

Thanks in advance
Jan 20 '07 #1
4 2847
cassbiz
202 100+
What I would like to do is run two queries with a single output.

for example my first query is:
Expand|Select|Wrap|Line Numbers
  1. <?
  2. $query = "(SELECT spacenummer FROM res WHERE arrival BETWEEN '$var_from' AND '$var_to' OR departure BETWEEN '$var_from' and '$var_to';)";
  3. ?>
  4.  

and the second query is

Expand|Select|Wrap|Line Numbers
  1. $query1 = "(SELECT spacenummer FROM spaces;)";
  2.  
The table spaces lists all of the available spaces.
The table res lists all booked spaces and dates.

I would like to find out if in the given date range a space is available then to show it in an output and/or give either a yes or no.

Thanks in advance

If anyone can help, still in need of assistance on this one. PLZZZZZZZZZZZZZ
Jan 27 '07 #2
ronverdonk
4,258 Expert 4TB
I hope this query is what you are looking for. It selects all spacenummers in spaces that are not in the result set of the first select set.
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM spaces WHERE spacenummer NOT IN  (
  2.    SELECT spacenummer FROM res 
  3.    WHERE '2006-11-30' BETWEEN arrival AND departure 
  4.    OR '2006-12-31' BETWEEN arrival AND departure
  5.                                                );
Ronald :cool:
Jan 28 '07 #3
cassbiz
202 100+
I hope this query is what you are looking for. It selects all spacenummers in spaces that are not in the result set of the first select set.
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM spaces WHERE spacenummer NOT IN  (
  2.    SELECT spacenummer FROM res 
  3.    WHERE '2006-11-30' BETWEEN arrival AND departure 
  4.    OR '2006-12-31' BETWEEN arrival AND departure
  5.                                                );
Ronald :cool:

Thank you, I will have to give it a go tomorrow for I can't see straight anymore today. Been a long one.

I will let you know of the results.
Jan 28 '07 #4
ronverdonk
4,258 Expert 4TB
Any results yet?

Ronald :cool:
Feb 13 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Gleep | last post by:
Hey Guys, I've got a table called Outcomes. With 3 columns and 15 rows 1st col 2nd col 3rdcol outcome date price There are 15 rows...
4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
9
by: Rich | last post by:
Thanks for the Help in my previous post. I've been working on this and it's almost what I want. I want to obtain the user's current age by comparing their date of birth (user inputs) to the...
5
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
7
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
2
by: boyleyc | last post by:
Hi all the following code works perfectly well. Basically it populates a series of check boxes on my form, depending on whether dlookup finds an associated record. The problem i have is that...
2
by: deepikashalini | last post by:
hi, Im storing Issue date in database. Issuedate stored as varchar. and then compare to Passing string date('03/06/2008') what is query to compare storing varchar date to passing string...
6
didajosh
by: didajosh | last post by:
Fund-----------LockUpDate----------Liquidity A-----------------12-31-2007-------------6 B-----------------02-29-2008-------------3 C-----------------05-31-2008-------------12 There are funds...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.