In a C# 2010 application, I am using a linq to sql statement to obtain a start datetime. If nothing is returned from the linq statement, I want to set a default date and time. However whenever I set the date to in the statement, the date ends up being 01/01/0001.
DateTime StartDateTime = rta.eransaction.Where(c => c.ResDate != null ).Select(c => c.ResDate).Max().GetValueOrDefault();
if (StartDateTime == null)
{
StartDateTime = Convert.ToDateTime("2010-08-14 12:33:36.590");
}
There will be times when I expect the ResDate from the query to be empty.
Thus can you tell me what I can do to the code above so that the startdatetime acutally gets the value I get to it in the code?