473,408 Members | 2,888 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,408 software developers and data experts.

Query to find the number of consecutive days

Hello All:
I am trying to write a query to determine the number of consecutive days that a conference room is available. The conference room is reserved for an entire day. People want to reserve the conference room for X number of days. They provide me with the starting day, ending day, and number of days the conference room is needed.

HOWEVER, we have 7 different conference rooms and conference room #1 may be available for 3 of the five days, but conference room #2 is available for the other two days. I don't want to say there is no conference room is available, but I do want to indicate that they will need to "room hop" between conference rooms.
I want to give a message like the following.
Room #1 is available for the first 3 days (20-Oct-2008 to 22-Oct-2008)
and
Room #2, 3, 4 is available for the last 2 days. (23-Oct-2008 to 24-Oct-2008)
-----
Table structure
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `tbl_availability` (
  2. `id_avail` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  3. `id_room` INT NOT NULL ,
  4. `id_date` BIGINT NOT NULL ,
  5. `str_avail_status` VARCHAR( 1 ) NOT NULL,
  6. `ts_last_update` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
  7. `str_updated_by` VARCHAR( 35 ) NULL ,
  8. INDEX ( `id_room` , `id_date` )
  9. ) ENGINE = MYISAM COMMENT = 'lists current room availabiltiy';

Sample data would look like
Expand|Select|Wrap|Line Numbers
  1. id_avail  id_room  id_date    str_avail_status  last_update str_updated by
  2. 1234      1         20081020   A
  3. 1235      1         20081021   A
  4. 1236      1         20081022   A
  5. 1237      1         20081023   N                      5-Oct-2008    RR
  6. 1238      1         20081024   N                      5-Oct-2008    RR
  7. 1240      2         20081020   N                      5-Oct-2008    RR
  8. 1241      2         20081021   A
  9. 1242      2         20081022   N                      5-Oct-2008    RR
  10. 1243      2         20081023   A
  11. 1244      2         20081024   A
If I know how many CONSECUTIVE days room 1, 2, 3,... is available starting on 20 Oct 2008, I am sure I can figure out the rest.

Thanks for reading...any suggestions are greatly appreciated.
--EasyTarget
Oct 9 '08 #1
1 3287
code green
1,726 Expert 1GB
I don't think you have provided enough information.
Where are the dates you refer to?
Oct 10 '08 #2

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

Similar topics

4
by: Orion | last post by:
Hi, This is kind of last minute, I have a day and a half left to figure this out. I'm working on a project using ms-sqlserver. We are creating a ticket sales system, as part of the system, I...
6
by: Bob | last post by:
Hullo Everybody What is the expression that I need to use to run a query that returns only records with exactly 10 NUMERIC characters CONTAINED in a field called "ProductNumber" There may...
1
by: Sue | last post by:
I have a large training database that contains many records of future training courses. For a course there could be only one class or multiple classes. Where there are multiple classes, each class...
1
by: tboyd24 | last post by:
Is there a way to show data based on if dates are consecutive. Im try to show only the people who have consecutive Vac days out of a list of 20,000 records.
5
by: Wired Hosting News | last post by:
I tried to be breif and give a scenario so as not to be overlooked because it was soooo long. Let me give you real world. I am a manufacturer of goods and produce 11 items that are distributed...
2
by: Wade | last post by:
I am pretty new to Access, especially writing code, but I found code on the web to do just what I want and it is posted below. It returns a field value from a previous record. I found the code at:...
3
by: TroyB | last post by:
I need a query formula to total consecutive days for dates. Employees are listed each time they are absent with a new date. Is this type of calculation possible without having two date fields? ...
3
by: Nelson | last post by:
Hi All, I want to look at what happens to stock prices after a certain number of consecutive up or down days. Let's say, for instance, I'd like to see where a stock's price is 5 days after a...
11
by: lenygold via DBMonster.com | last post by:
Hi everybody! This query is supposed to count consecutive years from the current year without OLAP. Input Table: ID DateCol 1 02/01/2006 1 01/01/2006 1 01/01/2005
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.