string[] formats = new[] { "{dd.MM.yyyy}", "{0:MM/dd/yyyy}", "{0:M/d/yyyy}" };
///FactryyDate
DateTime factryDate;
if (DateTime.TryParseExact(dt.Rows[i]["delevery_date"].ToString().Trim().Substring(0, 10), formats, System.Globalization.CultureInfo.InvariantCulture,
                          System.Globalization.DateTimeStyles.None, out factryDate))
{
    txtDeliDate.Text = factryDate.ToString("dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture);
}
dt.Rows[i]["delevery_date"].ToString().Trim().Substring(0, 10) is equals to '5/27/2015'

But it fails to convert I don't know why every time I resolve datetime problem it works for few days or week then again it gives some error.

Related posts

Recent Viewed