Home Unanswered Active Tags New Question

Testing for Overlapping Events with SQL

I know this is way sort of off topic but like the rest of you I'm developing a time / event scheduling app so I though I might save you some time and post this thing I've been banging my head against the wall working on. Namely since my app is being used to keep track off billable time I needed a way to make sure new events do not overlap any existing ones in my database.

Here's the SQL...

SELECT eventid from events WHERE(NOT((event_end < '" & newEventStartDate & "')
OR (event_start > '" & newEventEndDate & "')));"

Hope you find this helpful.

Dave
Asked by Dave Abad 4 years ago.
Replies
Thanks for sharing the code, Dave!
Comment posted by Dan Letecky 4 years ago.

As far as I know, without the NOT that would be.

SELECT eventid from events WHERE((event_end >= '" & newEventStartDate & "')
AND (event_start <= '" & newEventEndDate & "'));"

This is exactly the same

Answer posted by Tim Daldini 2 years ago.

Thanks, Tim!

Comment posted by Dan Letecky 2 years ago.
New Reply
This reply is
Your name (optional):

DayPilot for ASP.NET WebForms, DayPilot for ASP.NET MVC, DayPilot for Java