16 Replies - 1194 Views - Last Post: 24 February 2010 - 07:50 AM
#1
query
Posted 06 February 2010 - 07:57 AM
Replies To: query
#2
Re: query
Posted 06 February 2010 - 02:45 PM
SELECT {fields} FROM {table} WHERE RoomBooked = 'open' AND RoomDate BETWEEN #startdate# AND #enddate#
I can't be more specific as you posted no code or any current SQL statements you are trying.
#3
Re: query
Posted 06 February 2010 - 11:11 PM
#4
Re: query
Posted 11 February 2010 - 03:08 AM
timeID - Primary
TimeStart - date/time
TimeEnd - date/time
my query is like this
Select timeID FROM tblTime WHERE ((timeID BETWEEN timeStart='7:00:00 am' AND timeEnd='10:00:00 am'))
i want to display the timeID which is between from the time start and time end.. this is what a room scheduling was.
#5
Re: query
Posted 11 February 2010 - 06:04 AM
You also have a problem in the statement. See changes below
Select timeID FROM tblTime WHERE ((timeStart >= #"7:00:00 am# AND timeEnd <=#10:00:00 am#))
This post has been edited by CharlieMay: 11 February 2010 - 06:10 AM
#6
Re: query
Posted 20 February 2010 - 12:00 AM
//tblSched
SchedID AutoNumber
Room Text
TimeStart Date/Time Format(Short Time)
TimeEnd Date/Time Format(Short Time)
Day Text
/////
////Records
SchedId Room TimeStart TimeEnd Day
1 E101 7:00 10:00 MonWedFri
2 E102 11:00 13:00 MonWedFri
/////
Problem:
I want to display the room number with the givin time start and time end and the day
// This is the 1st query
Select Room FROM tblSched WHERE ((TimeStart >= # 7 :00 # AND TimeEnd <=#10:00 #)) AND (Day Like '%Mon%')
// this the result of 1st query
E101
// This is the 2nd query
SELECT Room FROM tblSched WHERE ((TimeStart >= # 8 :00 #) AND (TimeEnd <= # 9 :00 #)) AND (Day Like '%Mon%')
About this query, this result to a conflict of schedules. What should i do with this?
////Error in SQL
Error in WHERE clause near '#'
Unable to parse query text
i am using the data environment in vb6 to build the query
please help me with this. . . .
#7
Re: query
Posted 20 February 2010 - 09:41 AM
WHERE Day LIKE '*MON*'
Also...
Quote
Select Room FROM tblSched WHERE ((TimeStart >= # 7 :00 # AND TimeEnd <=#10:00 #)) AND (Day Like '%Mon%')
// this the result of 1st query
E101
// This is the 2nd query
SELECT Room FROM tblSched WHERE ((TimeStart >= # 8 :00 #) AND (TimeEnd <= # 9 :00 #)) AND (Day Like '%Mon%')
About this query, this result to a conflict of schedules. What should i do with this?
If you book a room on Monday from 7:AM - 10:AM
This Query
SELECT Room FROM tblSched WHERE ((TimeStart >= # 8 :00 #) AND (TimeEnd <= # 9 :00 #)) AND (Day Like '%Mon%')
Will not find a conflict as 7:Am is not greater than or equal to 8:AM so it will not be found as a conflict for that same room
This post has been edited by CharlieMay: 20 February 2010 - 09:45 AM
#9
Re: query
Posted 20 February 2010 - 07:02 PM
#10
Re: query
Posted 20 February 2010 - 08:18 PM
So
lets say you have txtStartTime.Text with 7:00 AM and txtEndTime.Text with 9:00 AM for Room E101 on Monday (Mon)
In your database you have an entry as
Room:E101 TimeStart: 8AM TimeEnd 11AM Day:MONWEDFRI
to find that with the above times I would try the following:
"SELECT Room FROM tblSched WHERE TimeStart BETWEEN #" & txtStartTime.Text & "# AND #" & txtEndTime.Text & "# AND TimeEnd BETWEEN #" & txtStartTime.Text & "# AND #" & txtEndTime.Text & "# AND Day LIKE '*MON*'"
This way if the starttime or endtime has a value that falls within your current times you want to book, it will show that room as unavailable.
#11
Re: query
Posted 20 February 2010 - 08:49 PM
#12
Re: query
Posted 21 February 2010 - 06:45 AM
SELECT Room FROM tblSched WHERE TimeStart BETWEEN # 7:00 # AND # 10:00 # AND TimeEnd BETWEEN # 7:00 # AND # 10:00 # AND Day LIKE '*MON*'"
And the result to that is E101
But, when i try this one,
SELECT Room FROM tblSched WHERE TimeStart BETWEEN # 8:00 # AND # 9:00 # AND TimeEnd BETWEEN # 8:00 # AND # 9:00 # AND Day LIKE '*MON*'"
it result to nothing, this schedule is conflict with the first one. But why didn't it produce the room number of the class schedule 7:00 to 10:00 monday @ e101.
#13
Re: query
Posted 21 February 2010 - 06:55 AM
#14
Re: query
Posted 21 February 2010 - 08:23 AM
oh men, i think i'm having a headaches with this.
#15
Re: query
Posted 21 February 2010 - 08:55 AM
You might be able to OR if StartTime between TimeStart and TimeEnd to check if the allotted slot is withing a larger booking.
SELECT Room FROM tblSched WHERE (TimeStart BETWEEN # 8:00 # AND # 9:00 # AND TimeEnd BETWEEN # 8:00 # AND # 9:00 #) OR (TimeStart BETWEEN #8:00# AND #9:00# OR TimeEnd BETWEEN #8:00# AND #9:00#) AND Day LIKE '*MON*'
So this way you are checking for both times to conflict or the start time or the end time.
You might run this through the Query Builder in Access for proper () placement.
|
|

New Topic/Question
Reply




MultiQuote




|