My problem :String was not recognized as a valid DateTime.
form:
To Date
EditFormatString="dd/MM/yyyy" CssClass="form-control select">
From Date
EditFormatString="dd/MM/yyyy" CssClass="form-control select">
public static string SetDate(string date)
{
string setdate = null;
if (date != null && date != "")
{
DateTime dt = DateTime.ParseExact(date, "d/M/yyyy", CultureInfo.InvariantCulture);
// for both "1/1/2000" or "25/1/2000" formats
setdate = dt.ToString("dd/MM/yyyy");
//DateTime date1 = Convert.ToDateTime(date);
//var date2 = date1.Date;
//var D = date2.Day;
//var M = date2.Month;
//var y = date2.Year;
//string monthStr = M.ToString("00");
//setdate = D.ToString() + "/" + monthStr.ToString() + "/" + y.ToString();
}
//if (date != null && date != "")
// setdate = DateTime.Parse(date).ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
return setdate;
}
i cant not solve this code .this code is not working .its give error.please any one sovle this problem .this code asp.net c# devexpress .
sanjida
4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Rafnas T PPosted Jul 26, 2017, 12:49 AM
Naveen BishtPosted Jul 25, 2017, 9:31 AM
Syeada Sanjida JahanPosted Jul 20, 2017, 2:42 AM
Debasis SahaPosted Jul 20, 2017, 2:22 AM
{
DateTime dt;
if (DateTime.TryParse(date.ToShortDateString(), out dt) && date > new DateTime(1900, 1, 1))
return true;
else
return false;
}