title: Find closest date in SQL Server
body: <p>I have a table <code>dbo.X</code> with <code>DateTime</code> <code>column Y</code> which may have hundreds of records.</p>
  
  <p>My Stored Procedure has parameter <code>@CurrentDate</code>, I want to find out the date in the <code>column Y</code> in above table <code>dbo.X</code> which is less than and closest to <code>@CurrentDate.</code></p>
  
  <p>How to find it?</p>