ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 13th, 2006, 06:43 AM
CrrazyChaz CrrazyChaz is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 3 CrrazyChaz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 42 sec
Reputation Power: 0
Question Searching For Conflicting Bookings

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 :-)

Reply With Quote
  #2  
Old April 2nd, 2007, 01:41 PM
CrrazyChaz CrrazyChaz is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 3 CrrazyChaz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 42 sec
Reputation Power: 0
Talking Problem Solved!!

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



Reply With Quote
  #3  
Old June 1st, 2010, 03:40 PM
onlineclick onlineclick is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2010
Location: US
Posts: 13 onlineclick User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 44 sec
Reputation Power: 0
Hi, I'm new to this :)*

Hi everyoneJust introduce myself: I am a man (says my wife), I am 50 years old (hmm, that looks bad isn't it?) and I am a terrible bad programmer (I say myself). My hobbies: computer (of course), my 17 years old son and of course my wife. I like to play billiard, I do a very little bit and very simple programming in VB and I try to make a site for my billiard-club in the near future. big respect !

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Searching For Conflicting Bookings


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap