DateTime Null Question

B

Brock Allen

You can't, as it's a value type. Same as an int. If you're looking for database
null semantics then you need to use an alternate data type that supports
the notion of null, like System.Data.SqlTypes.SqlDateTime.
 
S

Steve C. Orr [MVP, MCSD]

The Date variable type cannot be null. It must have a value.
Most people use Date.MinValue (or Date.MaxValue) to represent a null date in
their code.

Example:
Dim MyDate as Date = Date.MinValue

As for inserting it in the database, the other guys already specified that
DBNull.Value is what you'll want to use.

The better news is that in .NET 2.0 all variable types will be nullable.
Here's more info:
http://www.panopticoncentral.net/archive/2004/06/04/1180.aspx
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top