title: How can I prevent date overlaps in SQL?
body: <p>I have the following table structure for a hire table:</p>
  
  <pre><code>hireId int primary key
  carId int not null foreign key
  onHireDate datetime not null
  offHireDate datetime not null
  </code></pre>
  
  <p>I am attempting to program a multi-user system that does not allow onhire and offhire period for cars to overlap. I need to be able to add hires in a non sequential order. Also need to allow editing of hires.</p>
  
  <p>Any way to constrain the tables or use triggers etc to prevent overlaps? I am using entity framework so I would want to insert to the table as normal and then if it fails throw some catchable exception etc.</p>