<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx</link><description>I got an interesting email from a customer today, asking for my opinion on how to deal with the concept of &amp;#8220;Empty&amp;#8221; in relation to DateTime values. They had decided to use the DateTime.MinValue value as an indication that the DateTime was empty.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95031</link><pubDate>Wed, 24 Mar 2004 04:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95031</guid><dc:creator>Jon Galloway</dc:creator><description>Agree, this is a nice approach to this problem. This has been taken a bit further by the NullableTypes project: &lt;a target="_new" href="http://nullabletypes.sourceforge.net/"&gt;http://nullabletypes.sourceforge.net/&lt;/a&gt;</description></item><item><title>RE: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95034</link><pubDate>Wed, 24 Mar 2004 04:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95034</guid><dc:creator>kpako@yahoo.com (Dare Obasanjo)</dc:creator><description>Of course, they wouldn't need this hack if value types were nullable. :)</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95035</link><pubDate>Wed, 24 Mar 2004 04:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95035</guid><dc:creator>Steven Engelhardt</dc:creator><description>If you are going to all the effort of creating a new class, why not use an extra bool instead of DateTime.MinValue?</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95036</link><pubDate>Wed, 24 Mar 2004 04:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95036</guid><dc:creator>Thomas Tomiczek</dc:creator><description>How will this integrate with third party UI controls?</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95048</link><pubDate>Wed, 24 Mar 2004 04:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95048</guid><dc:creator>Eric Gunnerson</dc:creator><description>Steven,&lt;br&gt;&lt;br&gt;You could use an extra bool instead of a specific value, if you were willing for your types to be bigger.&lt;br&gt;&lt;br&gt;That may be a reasonable tradeoff in some situations.&lt;br&gt;&lt;br&gt;Thomas, the answer to your question is probably &amp;quot;not too well&amp;quot;.</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95054</link><pubDate>Wed, 24 Mar 2004 04:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95054</guid><dc:creator>Keith Patrick</dc:creator><description>I'm not really fond of the name, though, as the struct isn't necessarily empty; it's empty-able, although a better name escapes me</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95072</link><pubDate>Wed, 24 Mar 2004 06:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95072</guid><dc:creator>RichB</dc:creator><description>A library I wrote a couple of years ago requires each component of a Date to be undeclared - eg 5th May, unknown year - or 5th May, year 2001 or 2002 or 2003&lt;br&gt;&lt;br&gt;The only way to handle this was to create a wrapper around a date.&lt;br&gt;&lt;br&gt;BTW - any chance of extending the date class to support BC dates rather than AD (CE) dates? And any chance of WinForms supporting the whole range of DateTime dates in it's calendar control, rather than stopping at the OLE limit?</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95117</link><pubDate>Wed, 24 Mar 2004 08:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95117</guid><dc:creator>Jocelyn Coulmance</dc:creator><description>What about System.Data.SqlTypes.SqlDateTime ?&lt;br&gt;Isn't it what it's all about ?</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95132</link><pubDate>Wed, 24 Mar 2004 09:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95132</guid><dc:creator>Dietmar Leibecke</dc:creator><description>In our company we use an approach that was published in the Visual Basic Programmer's Journal in 2000. The article is availabe online via MSDN at &lt;a target="_new" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvbpj00/html/nullvalues.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvbpj00/html/nullvalues.asp&lt;/a&gt;&lt;br&gt;&lt;br&gt;The idea is called the &amp;quot;Alias Null concept&amp;quot;, where a constant value acts as a surrogate for a database NULL value.&lt;br&gt;&lt;br&gt;We have implemented a utility class NullValue that offers operations like bool IsNullAlias(object val) to check, if a current value is a Null Alias. Our windows forms data binding takes care of this, so database NULL values will be displayed correctly.&lt;br&gt;&lt;br&gt;Our persistence framework converts database NULL values into Alias Nulls when reading data in and writes database NULL values into the database when properties of persistent objects have an Alias Null value. Works pretty well for us.</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95133</link><pubDate>Wed, 24 Mar 2004 09:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95133</guid><dc:creator>Sebastian Weber</dc:creator><description>I did like Eric but took Sql Server's MinDate instead of DateTime.MinDate.</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95142</link><pubDate>Wed, 24 Mar 2004 10:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95142</guid><dc:creator>Johnny Hall</dc:creator><description>SqlTypes are not serializable (AFAIK).  They're also bound to SQL Server (duh!), which is no use if you need to use another DB.</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95189</link><pubDate>Wed, 24 Mar 2004 12:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95189</guid><dc:creator>Nicholas Paldino [.NET/C# MVP]</dc:creator><description>I have to admit, I don't like this issue either.  This is probably the only thing that irks me when it comes to dealing with value types.&lt;br&gt;&lt;br&gt;I can't admit to having a solution (having a new type that encapsulates the value type doesn't seem right, unless it is provided in the System namespace).&lt;br&gt;&lt;br&gt;Also, implementing INullable on value types doesnt seem like it would work either.&lt;br&gt;&lt;br&gt;For the solution you provided, you should have implemented INullable for completeness.&lt;br&gt;&lt;br&gt;Also, you could have recommended that they use the SqlDateTime structure, whcih provides null semantics.</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95241</link><pubDate>Wed, 24 Mar 2004 14:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95241</guid><dc:creator>Paul Tyng</dc:creator><description>I have done something similar in my own business objects.  The next step for your own nullable type is to implement IComparable so that you can sort on this column and IConvertible will allow you to pass this type directly to command objects and the like.  &lt;br&gt;&lt;br&gt;Of course for databinding for a property named BornOn of class Budweiser, binding will look for a property called BornOnIsNull to determine if its null or not, so going forward I've come to the conclusion that I should not expose my custom nullable types outside of my business objects, just use them internally.&lt;br&gt;&lt;br&gt;Paul</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95242</link><pubDate>Wed, 24 Mar 2004 14:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95242</guid><dc:creator>Paul Tyng</dc:creator><description>Nicholas: IConvertible lets a value type tell a command object its DBNull.Value.</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95600</link><pubDate>Wed, 24 Mar 2004 22:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95600</guid><dc:creator>ÿ</dc:creator><description>Dietmar,&lt;br&gt;&lt;br&gt;The &lt;a target="_new" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvbpj00/html/nullvalues.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvbpj00/html/nullvalues.asp&lt;/a&gt; is talking about VB 5/6 - in which this isn't really a major issue, since you would just use a Variant (which can handle Null).&lt;br&gt;&lt;br&gt;Seeya</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95744</link><pubDate>Thu, 25 Mar 2004 04:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95744</guid><dc:creator>Matt</dc:creator><description>Make you yearn for a generic called Nullable&amp;lt;T&amp;gt;.  ;-)&lt;br&gt;</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#95913</link><pubDate>Thu, 25 Mar 2004 11:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:95913</guid><dc:creator>Thomas Eyde</dc:creator><description>So why is DateTime sealed?&lt;br&gt;&lt;br&gt;This would do the trick if it weren't:&lt;br&gt;&lt;br&gt;public class EmptyDateTime : DateTime&lt;br&gt;{&lt;br&gt;  private EmptyDateTime() {}&lt;br&gt;  public static EmptyDateTime Empty;&lt;br&gt;}&lt;br&gt;&lt;br&gt;I have not worked with value types, so it could be the singelton pattern doesn't work here, or the Equals method must be overridden.</description></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#96306</link><pubDate>Thu, 25 Mar 2004 20:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:96306</guid><dc:creator>Sergio Acosta</dc:creator><description>I like the solution, but that name of 'EmptyDateTime' is quite ugly and missleading.&lt;br&gt;&lt;br&gt;It should've been NullableDateTime or something like that.&lt;br&gt;&lt;br&gt;</description></item><item><title>re: FrameworkUtilities</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#97071</link><pubDate>Sat, 27 Mar 2004 00:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:97071</guid><dc:creator>HumanCompiler - Erik Porter (.NET MVP) Blog</dc:creator><description /></item><item><title>.NET Happenings #24</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#97231</link><pubDate>Sat, 27 Mar 2004 06:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:97231</guid><dc:creator>MasterMaq.NET</dc:creator><description /></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#105866</link><pubDate>Thu, 01 Apr 2004 20:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:105866</guid><dc:creator>Cliff</dc:creator><description>What about adding NAD to DateTime?</description></item><item><title>re: Interesting Types and SqlTypes Tidbit</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#109491</link><pubDate>Thu, 08 Apr 2004 07:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:109491</guid><dc:creator>HumanCompiler - Erik Porter (.NET MVP) Blog</dc:creator><description /></item><item><title>.NET DateTime and Timezone: It Seems Simple, but It's Not</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#138890</link><pubDate>Sat, 22 May 2004 02:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:138890</guid><dc:creator>Mark Treadwell</dc:creator><description /></item><item><title>DateTime and Timezone</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#186089</link><pubDate>Sat, 17 Jul 2004 17:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:186089</guid><dc:creator>Ohad's WebLog</dc:creator><description /></item><item><title>re: Adding Emptiness to the DateTime class</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#190764</link><pubDate>Thu, 22 Jul 2004 01:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:190764</guid><dc:creator>Mirko Geffken</dc:creator><description>Or you could just hold your breath for another 8 mo. or so and use .NET 2.0 with their nullable types (or jump into the beta):&lt;br&gt;&lt;br&gt;DateTime? dt=new DateTime();&lt;br&gt;&lt;br&gt;and then&lt;br&gt;&lt;br&gt;if (dt.HasValue)&lt;br&gt;{&lt;br&gt;}</description></item><item><title>Eric Gunnerson e i NullableTypes di luKa</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#221673</link><pubDate>Fri, 27 Aug 2004 22:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:221673</guid><dc:creator>Web Log di Adrian Florea</dc:creator><description /></item><item><title>Re:</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#333629</link><pubDate>Tue, 28 Dec 2004 12:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:333629</guid><dc:creator>RebelGeekz </dc:creator><description>[&lt;a target="_new" href="http://itpeixun.51.net/"&gt;http://itpeixun.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://aissl.51.net/"&gt;http://aissl.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz003.freewebpage.org/"&gt;http://kukuxz003.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz001.51.net/"&gt;http://kukuxz001.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz003.51.net/"&gt;http://kukuxz003.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz005.51.net/"&gt;http://kukuxz005.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz002.51.net/"&gt;http://kukuxz002.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz004.freewebpage.org/"&gt;http://kukuxz004.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz007.51.net/"&gt;http://kukuxz007.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz001.freewebpage.org/"&gt;http://kukuxz001.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz006.51.net/"&gt;http://kukuxz006.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz002.freewebpage.org/"&gt;http://kukuxz002.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz004.51.net/"&gt;http://kukuxz004.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz008.51.net/"&gt;http://kukuxz008.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz009.51.net/"&gt;http://kukuxz009.51.net/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz005.freewebpage.org/"&gt;http://kukuxz005.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz006.freewebpage.org/"&gt;http://kukuxz006.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz007.freewebpage.org/"&gt;http://kukuxz007.freewebpage.org/&lt;/a&gt;][&lt;a target="_new" href="http://kukuxz009.freewebpage.org/"&gt;http://kukuxz009.freewebpage.org/&lt;/a&gt;]</description></item><item><title>PlanetZack  &amp;raquo; Blog Archive   &amp;raquo; Nullable types</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#659327</link><pubDate>Fri, 07 Jul 2006 22:26:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:659327</guid><dc:creator>PlanetZack  » Blog Archive   » Nullable types</dc:creator><description>PingBack from &lt;a rel="nofollow" target="_new" href="http://planetzack.wordpress.com/2006/07/07/nullable-types/"&gt;http://planetzack.wordpress.com/2006/07/07/nullable-types/&lt;/a&gt;</description></item><item><title>DateTime and IsEmpty &amp;laquo; M G Vinod Kumar&amp;#8217;s Technology Blog</title><link>http://blogs.msdn.com/ericgu/archive/2004/03/23/95011.aspx#2354502</link><pubDate>Tue, 01 May 2007 13:01:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2354502</guid><dc:creator>DateTime and IsEmpty « M G Vinod Kumar’s Technology Blog</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://mgvinod.wordpress.com/2006/08/03/datetime-and-isempty/"&gt;http://mgvinod.wordpress.com/2006/08/03/datetime-and-isempty/&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>