Null date value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If I need to assign a NULL value to a date variable, how would I go about
doing that? For right now I am using 01-01-2001, however I don't want to use
a "real" date if the date should really be NULL.

Thanks for the information.
 
Brad said:
If I need to assign a NULL value to a date variable, how would I go
about doing that? For right now I am using 01-01-2001, however I
don't want to use a "real" date if the date should really be NULL.

Thanks for the information.


Declare it as Object or use a 'WrappedDate' and assign Nothing to represent
Null.

Class WrappedDate
public Value as date
public sub New(value as date)
me.value =value
end sub
end class


Armin
 
Oenone said:
I use Date.MinValue to represent a "null" date. This works very nicely.

Unless your dealing with historical data and the MinValue of Date is the
same as a Date you really need to store in the field :)

Mythran
 
Brad said:
If I need to assign a NULL value to a date variable, how would I go
about doing that? For right now I am using 01-01-2001, however I
don't want to use a "real" date if the date should really be NULL.

I use Date.MinValue to represent a "null" date. This works very nicely.
 
Hehe. Then use DateTime.MaxDate and let the
great-great-great-great-great-great-great grandkids deal with the Y10K
problem.
 
Michael C# said:
Hehe. Then use DateTime.MaxDate and let the
great-great-great-great-great-great-great grandkids deal with the Y10K
problem.

Yeah...

Are you sure that January 1st, 9999 is far enough in the future though?

Mythran
 
Mythran said:
Yeah...

Are you sure that January 1st, 9999 is far enough in the future though?


Mythran

I'll be long dead and gone by then, and it'll be an S.E.P. (Somebody Else's
Problem)

Just wondering, but has anyone ever stored a Date in their database beyond
say -- just to throw an arbitrary date out there -- 5000 C.E.? I've seen
some databases with dates as high as 2399 C.E. (guy with like 4 life
sentences, no possibility of parole), but beyond that...? Just wondering if
maybe it's a common occurrence in some parts of the world to store such high
dates.
 
Michael said:
Just wondering, but has anyone ever stored a Date in their database
beyond say -- just to throw an arbitrary date out there -- 5000 C.E.?

Nothing that's supposed to be there. Loads of users have mis-keyed the year
when entering dates and we've ended up with dates in 9199 and things like
that.

The most common date in any of our systems is the 30th December 1899. Spot
the app that was originally written in VB6. :-)
 
Mythran said:
[Nullable date]

Unless your dealing with historical data and the MinValue of Date is the
same as a Date you really need to store in the field :)

The problem with this is that some controls (datetimepicker) allow the
selection of the 'MinDate' if there was no restriction set by the developer.
Thus I would not rely on 'MinDate' representing a null date when writing a
library.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top