title: How to generate a date for the given time?
body: <p>Using VB.NET and SQL Server 2005</p>
  
  <p>I want to generate a date according to the given Outtime, </p>
  
  <p>Am entering the value like</p>
  
  <pre><code>ID  Date       Intime   Outtime  Holiday
  
  001 23-02-2009 08:00:00 17:00:00 no
  001 24-02-2009 17:00:00 08:00:00 no
  001 25-02-2009 10:00:00 16:00:00 no
  001 26-02-2009 18:00:00 20:00:00 no
  001 27-02-2009                   yes
  </code></pre>
  
  <p>Expected Output</p>
  
  <p>Table1</p>
  
  <pre><code>ID  Date       Intime   Outtime  DateIn     Dateout
  
  001 23-02-2009 08:00:00 17:00:00 23-02-2009 23-02-2009
  001 24-02-2009 17:00:00 08:00:00 24-02-2009 25-02-2009
  001 25-02-2009 10:00:00 16:00:00 25-02-2009 25-02-2009
  001 26-02-2009 18:00:00 20:00:00 26-02-2009 27-02-2009
  001 27-02-2009     -        -        -         -
  
  …,
  </code></pre>
  
  <p>From the above table, DateIn column value should display same date column value, But Dateout column should display according to the Outtime. </p>
  
  <pre><code>In a first row – Intime is 08:00:00 and Outtime is 17:00:00, So Dateout should display the same date
  In a second row – Intime is 17:00:00 and Outtime is 08:00:00, So DateOut should display the next day date.
  In a third row – Intime is 10:00:00 and Outtime is 16:00:00, so Dateout should display the same date
  In a fourth row – Intime is 18:00:00 and Outtime is 21:00:00, so Dateout should display the next day date.
  In a fifth row – Holiday column value is yes, so it should not display any value in DateIn and DateOut
  </code></pre>
  
  <p>Dateout column should compare the Intime and Outtime value, if Outtime is less than Intime, Dateout column should display the next day date. </p>
  
  <p>If Holiday = Yes then It should display as a blank column </p>
  
  <p>For the above condition, How to make a sql query?</p>
  
  <p>Whether it is possible in vb.net, which is faster sql query or vb.net code?</p>
  
  <p>Need SQL Query or VB.NET code for the above condition.</p>