You can use this for nullable datetime types:
DateTime? d = null; if (d.HasValue) { //Do something here Console.WriteLine(d.Value.ToString()); } //...is the same as... Nullable<DateTime> dd = null; if (dd.HasValue) { //Do something here Console.WriteLine(dd.Value.ToString()); } On 9/6/07, Gray, Franklin W (RWG8) <[EMAIL PROTECTED]> wrote: > > I've always done something like below to handle dates that can be null > in the DB. Was curious if they (MS) every got around to coming up with > a date data-type that can accept null values. Is there a better way? > > > Public Property PaymentProcessedDateTime() As DateTime > Get > If Me._PaymentProcessedDateTime Is System.DBNull.Value Then > Return New Date > Else > Return CType(_PaymentProcessedDateTime, DateTime) > End If > End Get > > Set(ByVal Value As DateTime) > If Value = New Date Then > _PaymentProcessedDateTime = System.DBNull.Value > Else > _PaymentProcessedDateTime = Value > End If > End Set > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com > > View archives and manage your subscription(s) at > http://discuss.develop.com > =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com