I am trying to format a date. I get the date from the database in the dateTime format and i want to show only the date part not the time.
string date = dt.Rows[0]["declaration_date"].ToString();
string dateFormat = date.ToString("MM/DD/YYYY");
This is not working. Any help?
DateTime date = (DateTime) dt.Rows[0]["declaration_date"];declaration_dateis aDateTimecolumn you should not convert it to a string.DateTime result = dt.Rows[0].Field<DateTime>("declaration_date");