How can I compare a date in C# to "1/1/0001 12:00:00 AM")
You can use DateTime.MinValue
, which has exactly the same value:
if (e.CreatedDate == DateTime.MinValue)
To check if it equals the default, you can use the default keyword:
if (e.CreatedDate == default(DateTime))
"1/1/0001 12:00:00 AM" this is a string
datatype. so convert it to DateTime
.
if (e.CreatedDate == Convert.ToDateTime("1/1/0001 12:00:00 AM"))
{
//--- To Dos
}
But .NET Framework provide a default way to check this using
if (e.CreatedDate.Equals(DateTime.MinValue))
MSDN