You need to use nullable date times - the shortcut syntax would be DateTime?
(note the ?
at the end).
DateTime? hD = null;
if(!string.IsNullOrWhitespace(hire )) // string.IsNullOrEmpty if on .NET pre 4.0
{
hD = DateTime.Parse(hire);
}
You can test for hD.HasValue
and if it doesn't use DbNull.Value
instead.