Error - “Specified cast is not valid” in LINQ when DateTime field is null


You are trying to convert a non-standard format, so use this:

Try using DateTime.ParseExact.

 string dateStr = "15/07/2001";

 DateTime date = DateTime.ParseExact(dateStr, "dd-MM-yyyy HH:mm:ss",      System.Globalization.CultureInfo.InvariantCulture);


Comments

Popular posts from this blog

Validate Mobile Number with 10 Digits in ASP.Net