Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assign null to DateTime data type

Status
Not open for further replies.

Antzz

Programmer
Jan 17, 2001
298
US
Hi Folks,

Any idea on how to assign a null/empty value to a DateTime data type? If this is not possible then what is the alternative

Thx and appreciate it.

A
 
I ran into the same problem here: thread732-1090257

Basically you need to pick a date value that will represent null since .NET DateTimes are not nullable.

Jeff
[purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day

"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me
 
DateTime.MinValue is a good way to check for a bad date. If a date is supposed to be null, I set it to MinValue.
 
That's what I ended up doing as well. Actually, I ended up with 2 "special dates".

NullDate = DateTime.MinValue
ZeroDate - 01/01/1990 (place wasn't around before then)

This allowed me to distinguish between an empty date and "the beginning of time".

Jeff
[purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day

"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top