<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: canonical code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 21 Aug 2008 15:53:08 GMT</pubDate>
    <description>DZone Snippets: canonical code</description>
    <item>
      <title>Date Literals in SQL</title>
      <link>http://snippets.dzone.com/posts/show/756</link>
      <description>Due to international issues, there are many ways of representing a date in SQL code.  I prefer to use odbc canonical.&lt;br /&gt;&lt;br /&gt;dates&lt;br /&gt;&lt;code&gt;&lt;br /&gt;{d 'yyyy-mm-dd'}&lt;br /&gt;{d '2001-12-31'}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;timestamps&lt;br /&gt;&lt;code&gt;&lt;br /&gt;{ts 'yyyy-mm-dd hh:mm:ss'}&lt;br /&gt;{ts '2001-12-31 00:00:00'}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;times&lt;br /&gt;&lt;code&gt;&lt;br /&gt;{t 'hh:mm:ss'}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Don't let the ODBC in the name fool you, these work in Microsoft SQL Server, and through ODBC connections.&lt;br /&gt;I've tested it in Query Analyzer, Stored Procedures, ADO code (both OLEDB and ODBC providers), ADO.Net code (both SQLClient and ODBC).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;See Microsoft reference:&lt;br /&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcjetdate_time_and_timestamp_literals.asp&lt;br /&gt;&lt;br /&gt;It is a pity that there isn't some sort of SQL standard for date representation. Or maybe there is and I don't know it?</description>
      <pubDate>Wed, 21 Sep 2005 05:04:46 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/756</guid>
      <author>Will_Rickards (Will Rickards)</author>
    </item>
  </channel>
</rss>
