math - ColdFusion 9 - SQL Statement - Boolean Logic -
I plugged it on. And this would be a simple little mathematical logic problem. But for my life I can not get it to work properly.
Trying to avoid double booking material in the booking system. Current code ...
and schdate = #createODBCDate (schdate) # and (schstart & gt; = #createODBCTime (time) # and actend & lt; = #createODBCTime (actend) #) Basically try to do a check - if say that the start time is 2:00 and ends at 3 o'clock ... I have to check whether I Trying to overlap the book ... Try to say book at 2:15 pm ... stop saying this - conflict
Thought this is a mathematical argument - not a coldfusion is ... an air brain today ...
Thanx for direct - I think I would have thought this - still test ... seems to work under Dev link is given .
and schdate = #createODBCDate (schdate) #and schstart & lt; #contentabacktime (acting) #andactand & gt; #createODBCTime (time) #
Update: < / P> Below is a little more intuitive of the original query, basically reverse the comparison:
where date is column = # requested date # and start time column < # Requested end time #and endtime columns & gt; # Requested start time #
I remember a great thread on this subject: (ASCII illustration is a good touch :) Assume that your booking does not last for several days, It should work fine for the right time.
It is normal view to check each type of conflict:
- Overlap: i.e. requested at 9-10, but for 9: 30-11 AM There is a reservation from
- Falls within: the requested time is 10-11 AM, but there is an existing reservation for 9-12 PM
- included: either requested time 12-5PM , But a more elegant approach to the 2 - 3 PM
link has been mentioned. Basically, it reduces all those steps for a single filter. Where EF & gt; = SD and FS & lt; = ED If it finds a match, then you know that there is a conflict. The translation should look like this (untouchable).
Select from few columns Columns where # requested time # & gt; = Starttime column and # requested start date # & lt; = End time column and date column # # Requested date # NB: I deliberately left for clarity cfqueryparam obviously I I would suggest using it in your actual query.
Comments
Post a Comment