Null date

  • Thread starter Thread starter GB
  • Start date Start date
G

GB

Is there a function to set a null date in vb.net? Normally, I create a
const NULLDATE = "1/1/1900", but that becomes a drag at times. Especially,
handling a nulldate from SQL into a dataset.

Thank you,
Gary
 
GB said:
Is there a function to set a null date in vb.net? Normally, I create
a const NULLDATE = "1/1/1900", but that becomes a drag at times.
Especially, handling a nulldate from SQL into a dataset.

"Null dates" do not exist. A DateTime variable can hold a date and time
between 01.01.0001 and 31.12.9999, 23:59:59. If you want to store either a
DateTime value or Null (represented by DBNull.Value) in the same variable,
you have to declare it As Object.

dim d1,d2 as object

d1 = datetime.Now 'd1 holds a datetime object
d2 = DBNull.Value 'd2 holds a (DB)Null value

Concerning the database: Variables containing (references to) DBnull.Value
are stored as Null values in the database.
 
Back
Top