public static DateTime ToDateTime(string parameterValue, string parameterName) { try { if (parameterValue == null) { return(DateTime.Today); } if (parameterValue.Length <= 0) { return(DateTime.Today); } DateTime result; if (DateTime.TryParse(parameterValue, CultureInfo.CurrentCulture, DateTimeStyles.None, out result)) { return(result); } else { // if unable to parse, it is possible this is an OADate return(ConvertExt.FromOADate(Convert.ToInt32(parameterValue))); } } catch (ArgumentException) { throw new ReconciliationConversionException(String.Format(CultureInfo.CurrentCulture, "Unable to convert {0}, value = {1}, to DateTime", parameterName, parameterValue)); } catch (NotSupportedException) { throw new ReconciliationConversionException(String.Format(CultureInfo.CurrentCulture, "Unable to convert {0}, value = {1}, to DateTime", parameterName, parameterValue)); } catch (FormatException) { throw new ReconciliationConversionException(String.Format(CultureInfo.CurrentCulture, "Unable to convert {0}, value = {1}, to DateTime", parameterName, parameterValue)); } catch (OverflowException) { throw new ReconciliationConversionException(String.Format(CultureInfo.CurrentCulture, "Unable to convert {0}, value = {1}, to DateTime", parameterName, parameterValue)); } catch (Exception) { throw; } }