timespan.tt

<h2>Select timespan</h2>
<p>
The illustration below tries to show two timespans defined in a database.
The timespans is defined with a "start" and a "end" column.
"match timespan" is a fixed timespan defined by "t1" and "t2", which is
used to select all rows with a timespan overlapping (partially or totally) the
fixed timespan.
</p>

<div style="position: relative; height: 50px; color: black; font-weight: bold">

<div style="
    background: yellow;
    border-right: 3px solid white;
    border-left: 3px solid white;
    padding: 5px;
    position: absolute;
    top: 20px;
    left: 100px;
    height: 20px;
    width: 300px;
">match timespan</div>

<div style="
    background: red;
    border-right: 3px solid white;
    border-left: 3px solid white;
    padding: 5px;
    position: absolute;
    top: 0px;
    left: 0px;
    height: 20px;
    width: 300px;
    -moz-opacity: 0.6;
">timespan #1</div>

<div style="
    background: green;
    border-right: 3px solid white;
    border-left: 3px solid white;
    padding: 5px;
    position: absolute;
    top: 3px;
    left: 200px;
    height: 20px;
    width: 300px;
    -moz-opacity: 0.7;
">timespan #2</div>


</div>
<pre>
SELECT * from my_table
    WHERE
    start BETWEEN t1 AND t2
    OR
    end   BETWEEN t1 AND t2
    ;
</pre>