<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Global Nerdy &#187; SQL Server 2008</title>
	<atom:link href="http://www.globalnerdy.com/tag/sql-server-2008/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.globalnerdy.com</link>
	<description>Tech Evangelist Joey deVilla on software development, tech news and other nerdy stuff</description>
	<lastBuildDate>Mon, 22 Mar 2010 01:05:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tired: DateTime. Wired: DateTimeOffset!</title>
		<link>http://www.globalnerdy.com/2009/04/03/tired-datetime-wired-datetimeoffset/</link>
		<comments>http://www.globalnerdy.com/2009/04/03/tired-datetime-wired-datetimeoffset/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 13:21:29 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[date and time]]></category>
		<category><![CDATA[Sith Lord in Training]]></category>
		<category><![CDATA[SQL Server 2008]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/2009/04/03/tired-datetime-wired-datetimeoffset/</guid>
		<description><![CDATA[You’d think that with 10,000 years of date- and time-keeping under our belts, it would be easy to keep track of dates and times in a modern-day database. It’s a little trickier than you might think, according to The Death of DateTime?, an article in Bart Duncan’s SQL Weblog.
The gist of the article is pretty [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.globalnerdy.com/tag/sith-lord-in-training/"><img style="border-right-width: 0px; margin: 0px 0px 10px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" align="right" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/03/sith-lord-in-training.jpg" width="150" height="209" /></a>You’d think that with 10,000 years of date- and time-keeping under our belts, it would be easy to keep track of dates and times in a modern-day database. It’s a little trickier than you might think, according to <strong><em><a href="http://blogs.msdn.com/bartd/archive/2009/03/31/the-death-of-datetime.aspx">The Death of DateTime?</a></em></strong>, an article in <em><a href="http://blogs.msdn.com/bartd/">Bart Duncan’s SQL Weblog</a></em>.</p>
<p>The gist of the article is pretty simple: <strong>if you’re using SQL Server 2008 and want to store dates and times <em>unambiguously</em>, use the <code>datetimeoffset</code> type (introduced in SQL Server 2008) rather than the traditional <code>datetime</code>.</strong></p>
<p>Why? Because <code>datetimeoffset</code> is <code>datetime</code> with these key differences:</p>
<ul>
<li>The time value is stored internally in an unambiguous UTC format </li>
<li>The local time zone offset is stored along with the UTC time </li>
<li>It is capable of storing more precise times than <code>datetime</code> </li>
</ul>
<p><a href="http://blogs.msdn.com/bartd/archive/2009/03/31/the-death-of-datetime.aspx"><img style="border-right-width: 0px; margin: 0px 10px 10px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Desktop" border="0" alt="Desktop" align="left" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/04/calendar-and-clock.jpg" width="236" height="138" /></a>Duncan recommends that if you’re storing data in SQL Server 2008, <strong>you should almost always store date-and-time values in <code>datetimeoffset</code> rather than <code>datetime</code></strong>. It’s a good idea; I’d go even farther and suggest that if you’re programming using .NET 3.5, you should make use of the corresponding <code>DateTimeOffset</code> type instead of <code>DateTime</code>. You can read more about .NET 3.5’s DateTimeOffset type in this entry in <a href="http://www.danrigsby.com/blog/">Dan Rigsby’s blog</a> titled <strong><em><a href="http://www.danrigsby.com/blog/index.php/2008/08/23/datetime-vs-datetimeoffset-in-net/">DateTime vs. DateTimeOffset in .NET</a></em></strong>.</p>
<p>When might you want to use <code>datetime</code>? Duncan suggests that you should use it in those rare cases when you want to store time <em>ambiguously</em>. The example he provides is: “if you wanted a column to record the fact that all stores in a chain should open at 8:00am local time (whatever the local time zone may be), you should use <code>datetime</code>.”</p>
<p><em><a href="http://www.brentozar.com/archive/2009/04/sql-server-and-cloud-links-for-the-week-18/">Thanks to <strong>Brent Ozar</strong> for the link!</a></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2009/04/03/tired-datetime-wired-datetimeoffset/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
