How to check for default DateTime value?

I would probably make this really explicit:

// Or private, or maybe even public
internal static readonly DateTime MagicValueForNullDateTimeInNonNullableColumns
    = DateTime.MinValue;

Okay, so I’d make the name slightly less wordy, but you get what I mean. It doesn’t really matter much how you initialize that value – it’s clear what you’re trying to do.

(Of course, use a nullable type any time you can for this. I’m assuming the question was asked because you couldn’t do so in certain situations.)

Leave a Comment