0

I want to insert dates in my (SQLLite) database (format: yyyyMMdd). This dates shouldn't overlap the same time.

I tried to use this:

SELECT COUNT(*) FROM termine WHERE string = "" AND ((startDay BETWEEN 20151007 AND 20151009) OR (endDay BETWEEN 20151007 AND 20151009))

Problem: If the database contains values like startDay = 20151006 and endDay = 20151010, my method won't work, because the dates are not between the others.

So, what is the easiest way to check if a date is in the range of another?

Cœur
  • 37,241
  • 25
  • 195
  • 267
ForJ9
  • 735
  • 8
  • 24
  • Can you clarify what you mean by *This dates shoudln't overlap the same time.*? – user1717828 Oct 06 '15 at 17:37
  • Of course. You have a period of time (e.g. 20151006 to 20151008). Now I have a seconds period oft time (e.g. 20151005 to 201251009). In this example the second overlaps the first perdiod of time and this is what I want to detect. My code only works if the second period of time is beetween the first (e.g.20151006-20151007). – ForJ9 Oct 06 '15 at 18:39

0 Answers0