1
First thing to note that there is no such thing as "database date format".
Are you using SQL Server? What is the datatype of MembershipValidity? Is it DateTime or VarChar?
What is the datetime format in regional settings of your computer? This all matters.
0
Please once try below code:-
try
{
string db_Date = dt.Rows[0]["MembershipValidity"].ToString();
DateTime MembershipValidity = Convert.ToDateTime(db_Date );
}
catch(Exception)
{
throw;
}