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

Detecting Conflict Day and Time

lotus18
866 512MB
Hello World

I have a problem in detecting the conflict schedule (Day and Time).

Day
1. M
2. T
3. W
4. TH
5. F
6. S
7. M/TH <---My problem :(
8. T/F <---My problem :(
9. W/S <---My problem :(

Where: (M='Monday', [T]='Tuesday', and so on...)

Let's say I have this existing schedule on my database:

Expand|Select|Wrap|Line Numbers
  1.    Monday(Day)   7:00 AM(TimeIN)   8:00 AM(TimeOut)   AVR(Rooom)
  2.  
Here's my sample code and it is working but if the Day='M/TH' or Day='T/F' or Day='T/F' it can save the record even if it has already a schedule for that (refer to sample above).

Expand|Select|Wrap|Line Numbers
  1. Public Function Conflict(ByRef adConnection As ADODB.Connection, ByRef adRecordset _
  2. As ADODB.Recordset, ByRef Day As String, ByRef Room As _
  3. String, ByRef Course As String, ByRef TimeStarted As Date, ByRef TimeFinished As _
  4. Date) As Boolean 'ByRef Subject As String,
  5.     Conflict = False 'Default value
  6.  
  7.     'Opens and checks the connection
  8.     SetConnection
  9.     CheckConnection adRecordset
  10.  
  11.     adRecordset.Open "Select * From LoadSchedules Where " & _
  12.     "Day='" & Day & "' And Rooms.Title='" & Room & "' And Courses.Title='" & _
  13.     Course & "' And (TimeStarted Between #" & TimeStarted & "# And #" & _
  14.     TimeFinished & "# Or TimeFinished Between #" & TimeStarted & "# And #" & _
  15.     TimeFinished & "#)", dbConnection, 1, 1
  16.  
  17.     'Checks if there is duplicate title
  18.     If adRecordset.RecordCount > 0 Then
  19.         Conflict = True
  20.     Else
  21.         Conflict = False
  22.     End If
  23. End Function
  24.  
Any solution will be greatly appreciated : )

Rey Sean
Dec 2 '07 #1
14 3505
9815402440
180 100+
hi
replace 'or' in the bold line with 'and'
adRecordset.Open "Select * From LoadSchedules Where " & _
"Day='" & Day & "' And Rooms.Title='" & Room & "' And Courses.Title='" & _
Course & "' And (TimeStarted Between #" & TimeStarted & "# And #" & _
TimeFinished & "# Or TimeFinished Between #" & TimeStarted & "# And #" & _
TimeFinished & "#)", dbConnection, 1, 1

regards
manpreet singh dhillon hoshiarpur
Dec 3 '07 #2
lotus18
866 512MB
hi
replace 'or' in the bold line with 'and'
adRecordset.Open "Select * From LoadSchedules Where " & _
"Day='" & Day & "' And Rooms.Title='" & Room & "' And Courses.Title='" & _
Course & "' And (TimeStarted Between #" & TimeStarted & "# And #" & _
TimeFinished & "# Or TimeFinished Between #" & TimeStarted & "# And #" & _
TimeFinished & "#)", dbConnection, 1, 1

regards
manpreet singh dhillon hoshiarpur
Hi

This query is working well, if you replace OR with AND it cannot detect conflict. What am I asking is that how can I detect conflict

Note:
'M/TH' means Monday or Thursday... they contain same schedule. It should not add a new schedule for Monday or Thursday.

Like what I said, if there is existing Day='M', then when I add a new schedule
Day='M/TH' it should prompt conflict (Assuming they have both the same room, course, and time)

Rey Sean
Dec 3 '07 #3
lotus18
866 512MB
Hello

Is there anyone can help me???
Dec 3 '07 #4
CyberSoftHari
487 Expert 256MB
Better you post it in Sql Server forum. There you can get it.
Dec 3 '07 #5
lotus18
866 512MB
Better you post it in Sql Server forum. There you can get it.
Hello

I'm calling all the experts that could help me

Please help :(
Dec 4 '07 #6
Mohan Krishna
115 100+
Hi Lotus

If I got ur problem.....
Can't u change the database field width? To store 4 characters "M/Th"...

R u storing in the same way already?
Dec 4 '07 #7
lotus18
866 512MB
Hi Lotus

If I got ur problem.....
Can't u change the database field width? To store 4 characters "M/Th"...

R u storing in the same way already?
Hi Mohan

Thanks for responding. All I thought that no one could help me out right here :(

Here's my database structure: click

I posted it on sql forum but unfortunately no one wants to help me :(


Rey Sean
Dec 4 '07 #8
Mohan Krishna
115 100+
Hi Mohan

Thanks for responding
:
:
I posted it on sql forum but unfortunately no one wants to help me :(
Rey Sean
Hi Lotus
Here what I mean to say is..... r u storing M in one record and in a conflict record M/Th or otherwise u want to get M schedule from one record and Th schedule from other?
So, as I am in a bit confusion...
Dec 4 '07 #9
lotus18
866 512MB
Hi Lotus
Here what I mean to say is..... r u storing M in one record and in a conflict record M/Th or otherwise u want to get M schedule from one record and Th schedule from other?
So, as I am in a bit confusion...
Hi Mohan

I have these records on my Day Table
  1. M
  2. T
  3. W
  4. TH
  5. F
  6. S
  7. M/TH
  8. T/F
  9. W/S

Let say if I have this existing schedule:
  • ScheduleID = 10001
  • StartTime = 8:30 AM
  • EndTime = 1:00 PM
  • Day = M
  • Room = AVR
  • Course = BSN

Then If I add this new entry
  • ScheduleID = 10002
  • StartTime = 9:00 AM
  • EndTime = 10:00 AM
  • Day = M/TH
  • Room = AVR
  • Course = BSN

This should prompt a conflict in schedule because there is already a schedule for monday, then the new entry shouldn't be added. : )

Note: M/TH means 'Monday' or 'Thursday', I used this if they have both the same schedule. Because it would become redundant if add a new schedule for monday and add another for thursday with the same day, time, room and course : (

Rey Sean
Dec 4 '07 #10
Mohan Krishna
115 100+
  1. M
  2. T
  3. W
  4. TH
  5. F
  6. S
  7. M/TH
  8. T/F
  9. W/S

Note: M/TH means 'Monday' or 'Thursday', I used this if they have both the same schedule. Because it would become redundant if add a new schedule for monday and add another for thursday with the same day, time, room and course : (
Rey Sean
Hi Lotus
Can't u put validation when u r entering/adding a new schedule on
- Day and Time
- and, if required, Room and Course

Can't u use InStr( ) for getting the M or Th?
Am I getting ur problem?
Dec 4 '07 #11
lotus18
866 512MB
Hi Mohan

I'm planning to change the T to TU as Tuesday so that if I used LIKE operator in sql statement it cannot select the records of TH or M/TH. But there's one problem, if I already have a schedule on 'M' and I want to add another same schedule that is 'M/TH'.
Dec 4 '07 #12
try to change it to = instead of LIKE. It is diff. between LIKE and =.
Nov 9 '13 #13
CyberSoftHari
487 Expert 256MB
Just try Sql query
Expand|Select|Wrap|Line Numbers
  1. Dim strSql as String
  2. for i = 0 to UBound(Split(Day,"/"))
  3. <Asigen strDayStringHere by spliting Day by "/"
  4.  
  5.  strSql = "Select * from tblTableName WHERE Day like %'" strDayStringHere "'% and <other criteria>"
  6. ...
  7. ...
  8.  
  9.  
Note: 1. Day maybe a data type so use ShedDay
2. If record count is > 0 then days are repeated.
Nov 11 '13 #14
CyberSoftHari
487 Expert 256MB
if I already have a schedule on 'M' and I want to add another same schedule that is 'M/TH'...
plan your procedure first.
M - have some work.
M/TH - Have <another work> or <same work>?
Nov 11 '13 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Chad | last post by:
I have COM component embedded on html page. It has version 1.0.0.1 (by default). I have converted it in cab file. Code of html is something like: <HTML><HEAD></HEAD><BODY><OBJECT...
0
by: VHR | last post by:
Hi, I apologize for posting this a second time, but no one replied from the other group where I posted it. I have a design master and 4 replicas that I have successfully synced on about 4-5...
16
by: Vadim Biktashev | last post by:
Hello all I would like to give a certain name to a certain global variable. Unfortunately, this name is already used in math.h for a mathematical function. Worse, I do need to use maths library...
1
by: Kuriandungu | last post by:
Hi guys I've read the posts on Write conflict entered in this forum (along with some from kbAlertz and microsoft) and i have tried all the solutions without success. let me give you some background....
79
by: VK | last post by:
I wandering about the common proctice of some UA's producers to spoof the UA string to pretend to be another browser (most often IE). Shouldn't it be considered as a trademark violation of the...
1
lotus18
by: lotus18 | last post by:
Hi This is a follow-up post from my post (please click here) as CyberSoftHari suggested me to post it here. These are the tables that I've made: Schedules -ScheduleID -StartTime
14
lotus18
by: lotus18 | last post by:
Hello all I have these records on my Day Table for my complete database table please click here 1. M 2. T 3. W 4. TH 5. F 6. S
10
by: themadjester | last post by:
This is weird, I know what an IP address conflict is, and how to avoid it, but this problem seems atypical - and apparently client side? Basically I have a router internet network, it is DHCP and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.