snipt

Ctrl+h for KB shortcuts

SQL

Casting a Datetime to Date Sqlserver 2008

cast(getdate() As Date)
https://snipt.net/embed/842fae8370d256c3ff55a2a5a1656f88/
https://snipt.net/raw/842fae8370d256c3ff55a2a5a1656f88/
842fae8370d256c3ff55a2a5a1656f88
sql
SQL
1
2016-09-26T19:25:40
True
False
False
Feb 13, 2014 at 02:52 PM
/api/public/snipt/113504/
casting-a-datetime-to-date-sqlserver-2008
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">cast</span><span class="p">(</span><span class="n">getdate</span><span class="p">()</span> <span class="k">As</span> <span class="nb">Date</span><span class="p">)</span> </span></pre></div> </td></tr></table>
casting, date, datetime, sqlserver

SQL

sql server today's date selector

-- nice today date selector
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
https://snipt.net/embed/13abbbcdabb7a8f9460863cee4fe9d98/
https://snipt.net/raw/13abbbcdabb7a8f9460863cee4fe9d98/
13abbbcdabb7a8f9460863cee4fe9d98
sql
SQL
2
2016-09-25T20:11:27
True
False
False
/api/public/snipt/103238/
sql-server-todays-date-selector
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c1">-- nice today date selector</span> </span><span id="L-2"><a name="L-2"></a><span class="k">SELECT</span> <span class="n">DATEADD</span><span class="p">(</span><span class="n">dd</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">DATEDIFF</span><span class="p">(</span><span class="n">dd</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">GETDATE</span><span class="p">()))</span> </span></pre></div> </td></tr></table>
sqlserver
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.