I've taken your idea a step further. Below is WORKING
code. Just copy and paste into a asp file. Please
CHECK it as I have added another if statement that I
think covers all possiblities. I will add the TIME
later (guessing it should still work), this is yours
to do as you wish, and thanks a million!
'CODE PROVIDED BY DONTWORRY AVA. AT
'PLEASE NO KUDOS JUST PASS IT FORWARD
'THANKS TO KEN SCHAEFER FOR THE WISDOM
response.write "Overlapping date function<BR>"
dim EstDate, EedDate
dim PstDate, PedDate
EstDate = date()
EedDate = date() +9
same_page = Request.ServerVariables("SCRIPT_NAME")
PstDate = request.form("proposedSTDate")
PedDate = request.form("proposedEDDate")
response.write "Existing Dates "& EstDate &" to "
response.write "Proposed Dates " &PstDate &" to " &
if request.form("token") ="" then
<form action="<%=same_page%>" method="POST">
Proposed StartDate<input type="text"
Proposed EndDate<input type="text"
<input type="submit" value="submit"
<input type="hidden" name="token" value="1">
if FORMATDATETIME(EstDate) < FORMATDATETIME(PstDate)
AND FORMATDATETIME(EedDate) > FORMATDATETIME(PedDate)
response.write "Yes Overlapping 1"
elseif FORMATDATETIME(EstDate) >
FORMATDATETIME(PstDate) AND FORMATDATETIME(EedDate) <
response.write "Yes Overlapping 2"
elseif FORMATDATETIME(EstDate) <
FORMATDATETIME(PedDate) AND FORMATDATETIME(EedDate) >
response.write "Yes Overlapping 3"
elseif FORMATDATETIME(EstDate) <
FORMATDATETIME(PstDate) AND FORMATDATETIME(EedDate) >
response.write "Yes Overlapping 4"
response.write "No Overlapping"
--- Ken Schaefer <ken@a...> wrote:
> From: "dont worry" <aspmailbox@y...>
> Subject: [proasp_codeclinic] Re: reservation system
> based on date and time
> : <question_by_example>
> : How should I set this up and how will it work.
> : User (A) enters a class date of
> : <startdatetime>3/4/2002 9:00am</startdatetime>
> : <enddatetime>3/4/2002 9:45am</enddatetime>
> : Should i insert this in to 2 diff. columns
> : (startdatetime) & (enddatetime) or 4 diff. columns
> : (startdate)&(starttime) & (enddate)& (endtime)?
> Just two. Your attribute is a starting date/time,
> and an ending date/time - why do you need extra
> : User (B) enters a class date of
> : <startdatetime>3/4/2002 8:00am</startdatetime>
> : <enddatetime>3/4/2002 9:30am</enddatetime>
> : In the above example the User (B)'s TIME overlap
> : User (A) time so I should give an error.
> : What will the query look like to ensure that time
> : not overlap like this? Will it be between
> : startdatetime & enddattime or some kind of date
> : difference?
> : </question_by_example>
> : Is there any online reference or examples I could
> Draw a line that indicates the length of time of a
> proposed booking. Now draw more lines to indicate
> possible overlaps (eg see rudimentary diagram
> below). Red is the proposed booking. Blue are the
> overlapping bookings.
> The above are all the possible ways a proposed
> booking can overlap with an existing booking. If
> none of the conditions exist, you enter the proposed
> booking in the database.
> Thus if (ST=StartTime, ET=EndTime)
> ExistingST < ProposedST AND ExistingET >
> ProposedET -- covers first two possibilities
> ExistingST > ProposedST AND ExistingET <
> ProposedET -- covers 3rd possiblity
> ExistingST < ProposedET AND ExistingET >
> ProposedET -- covers 4th possiblity
> then you have an overlapping condition. If the
> Recordset is EOF then there is no overlap, and you
> can insert the new booking.
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage