title: sql query for logins for days
body: <p>My question table:</p>
  
  <pre><code>userid       logintime            logouttime
  1           1/8/17 10am           1/8/17  9pm
  2          1/8/17 9am           1/8/17  10pm
  3          1/8/17 11am          1/8/17  6pm
  1          2/8/17 11am          2/8/17  7pm
  2          2/8/17 6am           2/8/17  4pm
  3          2/8/17 8am           2/8/17  3pm
  1          3/8/17 4am          3/8/17  1pm
  2          3/8/17 11am         3/8/17  11pm
  3          3/8/17 5am          3/8/17  5pm
  </code></pre>
  
  <p>I need sql query for the time gap between by a user from 1st day to second day </p>
  
  <p>Example answer table:</p>
  
  <pre><code>userid      logintime          logouttime            timegap
  1          1/8/17 10am          1/8/17  9pm          25 hours
  1          2/8/17 11am          2/8/17  7pm
  </code></pre>
  
  <p>time gap by userid=1 from  1/8/17 10am  to  2/8/17 11am is
   25 hours</p>