|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi there Folks,
Got a bit of a problem, and hoping someone out there can shed some light on the matter. I've set up a simple aircraft booking system, and have got to the part where the database searches for conflicting bookings. Booking Already In DB: Depart Date 01/08/06 Depart Time 08:00 Arrive Date 02/08/06 Arrive Time 20:00 Now if you try and make a booking such as: Depart Date 01/08/06 Depart Time 07:45 Arrive Date 02/08/06 Arrive Time 15:00 Then it will flag up a conflict... HOWEVER, if you make the following booking (IE, only spans across 1 day)... Depart Date 01/08/06 Depart Time 08:00 Arrive Date 01/08/06 Arrive Time 20:00 ...Then it allows you to book the conflict! Can Anyone Help?! Here's The Code... Code:
qry="SELECT * FROM tblBookings"
qry=qry & " WHERE "
qry=qry & "(tblbookings.fromtime >= #" & FormatDateTime(Request.Form("fromtime"), 4) & "# AND "
qry=qry & "tblbookings.totime <= #" & FormatDateTime(Request.Form("totime"), 4) & "#) AND "
qry=qry & "(tblbookings.fromdate >= #" & FormatDateTime(Request.Form("fromdate"), 1) & "# AND "
qry=qry & "tblbookings.todate <= #" & FormatDateTime(Request.Form("todate"), 1) & "#) AND "
qry=qry & "tblbookings.aircraft_reg = '" & Request.Form("aircraft_reg") & "'"
Set Result1 = myConn.Execute(QRY)
if Result1.EOF = true then
'Create Record
sql="INSERT INTO tblBookings ([user],[aircraft_reg],[fromdate],"
sql=sql & "[fromtime],[todate],[totime],[remarks])"
sql=sql & " VALUES "
sql=sql & "('" & Request.Form("user") & "',"
sql=sql & "'" & Request.Form("aircraft_reg") & "',"
sql=sql & "'" & Request.Form("fromdate") & "',"
sql=sql & "'" & Request.Form("fromtime") & "',"
sql=sql & "'" & Request.Form("todate") & "',"
sql=sql & "'" & Request.Form("totime") & "',"
sql=sql & "'" & Request.Form("remarks") & "')"
'response.write sql
Myconn.Execute SQL,recaffected
'find ref of new entry
'Query = "SELECT id FROM tblBookings"
'Set Result = myConn.Execute(Query)
'while not Result.EOF
'id = Result("id")
'Result.MoveNext
'Wend
Response.Redirect "bookings.asp"
'Response.Redirect "viewnews.asp?id="&id
else
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Please Wait...</title></head>
<%
response.redirect "dupbookings.asp?aircraft_reg="& Request.Form("aircraft_reg") &"&fromdate="& Request.Form("fromdate") &"&todate="& Request.Form("todate") &"&fromtime="& Request.Form("fromtime") &"&totime="& Request.Form("totime")
end if
%>
<body>
</body>
</html>
Can Anyone Shed Any Light On The Matter? Thanks :-) |
|
#2
|
|||
|
|||
|
Hi folks,
Happy to report that I've solved the problem I posted on here ages ago. I thought I'd let you know the answer just in case anyone else falls upon the problem... Code:
qry="SELECT * FROM tblBookings"qry=qry & " WHERE "
qry=qry & "((#"&fromdate&"# BETWEEN tblbookings.fromdate AND tblbookings.todate"qry=qry & " OR "
qry=qry & "#"&todate&"# BETWEEN tblbookings.fromdate AND tblbookings.todate)"qry=qry & " OR "
qry=qry & "(tblbookings.fromdate BETWEEN #"&fromdate&"# AND #"&todate&"#"qry=qry & " OR "
qry=qry & "tblbookings.todate BETWEEN #"&fromdate&"# AND #"&todate&"#)) AND "
qry=qry & "tblbookings.aircraft_reg = '"&Request.Form("aircraft_reg")&"'"
Set Result1 = myConn.Execute(QRY)
if Result1.EOF = true then
'Create Record
![]() |
|
#3
|
|||
|
|||
|
Hello everybody!
Hi,My name is Tina.I'm excited to be part of this large and growing forum of great people and thankyou all for making me feel welcome. I just joined today.My special interests or skills are:- HTML- SEO- Web design- Internet businessI am happy to help others that need it and offer advice where possible
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Searching For Conflicting Bookings |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|