473,388 Members | 1,340 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,388 software developers and data experts.

dates - vacancies and bookings

I have:
a) a calendar table (tblCalendar) holding consecutive dates.
b) a vacancies table (tblVacancies) holding start and end dates of
vacancies
c) a bookings table (tblBookings holding start and end dates of each
booking for a given vacancy.

Can anyone tell me how I can generate, with queries, start and end
dates for the vacant periods of a given vacancy? e.g.

tblVacancy (for a given vacancy) holds: fldStart = 10/1/04, fldEnd =
15/3/04
tblBookings holds, say, three bookings (periods where the vacancy has
been filled)
: fldStart = 20/1/04, fldEnd =
25/1/04
fldStart = 7/2/04, fldEnd =
9/2/04
fldStart = 19/2/04, fldEnd =
25/2/04

I want a query which will produce (the periods during which the
vacancy is still vacant:
fldStart = 10/1/04, fldEnd =
19/1/04
fldStart = 26/1/04, fldEnd =
6/2/04
fldStart = 10/2/04, fldEnd =
18/2/04
fldStart = 26/2/04, fldEnd =
15/3/04

Would be most grateful for anyone's help.
Brian
Nov 12 '05 #1
2 1712
fp
Someone smarter than me may have this one in the can but I can give you my
take on it.

Consider changing the start/end date to start date and duration, like number
of days. You also need to know the rules around inclusion of the end points.
Do you count both start and end dates or do you only count the start date,
end date or neither? Consider a hotel system. You check in after 2pm and
check out by 11am. The first day is counted and the last is not. This is
traditional in the hotel industry and can be applied to other applications
as well.

Off the top of my head you may want to create a class for a booking that
contains the date and duration. You will also need some logic to string
these together to compare the start/duration and come up with any overlaps
and gaps. What you would end up with is a collection of classes that are
either booked or vacant. You can still do this without classes by doing
query for all records and looping through them looking for the end of one
period and the start of the next and calculating the difference.

I did one of these quite a while ago and from what I remember it was quite
complicated by some outside factors, but it still took me a few weeks to
work out all the details and to develop tests to check the logic.

--
******************************
Fred Parker
Lynn Consulting Group, L.L.C.
http://www.lynnconsultinggroup.com
******************************
Nov 12 '05 #2
Hi,
Thanks for your reply.
Would rather not get involved in classes - probably a steep learning
curve for me!!
However, your suggestion of looping through all the records is a good
one, presumably using vb.
Understand your point re counting the first/end days.
Thanks again for your help
Brian

"fp" <et****************@hotmail.com> wrote in message news:<9a******************@nwrddc01.gnilink.net>.. .
Someone smarter than me may have this one in the can but I can give you my
take on it.

Consider changing the start/end date to start date and duration, like number
of days. You also need to know the rules around inclusion of the end points.
Do you count both start and end dates or do you only count the start date,
end date or neither? Consider a hotel system. You check in after 2pm and
check out by 11am. The first day is counted and the last is not. This is
traditional in the hotel industry and can be applied to other applications
as well.

Off the top of my head you may want to create a class for a booking that
contains the date and duration. You will also need some logic to string
these together to compare the start/duration and come up with any overlaps
and gaps. What you would end up with is a collection of classes that are
either booked or vacant. You can still do this without classes by doing
query for all records and looping through them looking for the end of one
period and the start of the next and calculating the difference.

I did one of these quite a while ago and from what I remember it was quite
complicated by some outside factors, but it still took me a few weeks to
work out all the details and to develop tests to check the logic.

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Simon Harris | last post by:
Hi All, Ok - I'll confess from the start, this is more about application logic that ASP, being an ASP programmer, I guessed you people might be able to help! :) I have built a room bookings...
6
by: Dan Evans | last post by:
Hi, Can anyone help me on a little problem I am having with some SQL - in particular on a subquery. I am setting up a database in Access for a voluntary group which runs
15
by: plaztik8 | last post by:
Hello, Can someone please help me with a query? The table looks like this: BookedRooms =========== CustomerID RoomID BookDateID
10
by: Brent Webster | last post by:
This problem seems to occur dependant on the computer system settings. I have no issues when the system date is set as M/d/yyyy but I do have a problem with the system date set as d/M/yyyy. I...
5
by: Mal | last post by:
Hello. I have a database that tracks reservations at a campground. I want to be able to make a calendar type report that shows how many people are here in given period. Stored for each...
1
by: Peter Bailey | last post by:
I have a student table with studentid as pk and an enrolment date field as date. I have made a qry to group on date and count the number of enrolments for a particular day. What this doesnt...
0
by: Tony | last post by:
Aloha, I have a problem that I can't think of a (easy) solution for. I'm building a web app (asp/access) that will allow people to book a cruise on a 24 passenger yacht that goes around the...
1
by: yk | last post by:
I am setting up a simple hotel reservation application which have two dates, i.e. CheckIn and CheckOut. I would like to construct a graph based on a crosstab query. Therefore, I need to have...
8
by: Mike Jolley | last post by:
Hello First off, I'm a student so I'm pretty new to C++, and therefore I have probably made a stupid mistake somewhere. Anyway Ive been trying to fix this 5 hours straight now, so i need a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.