Reputation: 14668
My MySQL database has a date field in the format:
yyyy-mm-dd
but in ASP .NET this shows as:
9/14/2009 12:00:00 AM
in both the ItemTemplate and EditItemTemplate.
How do I format the field to display properly?
Upvotes: 0
Views: 1600
Reputation: 1
DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
qry = "select taxpercentage from tbl_tax where effectivedate contains '" + dt+ "'";
con.returnscalar(qry); what is wrong in this
Upvotes: 0
Reputation: 21704
You can use ToShortDateString() method of DateTime. You also can use something like this:
DateTime dateTimeObject = Convert.ToDateTime("9/14/2009 12:00:00 AM");
dateTimeObject.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
Upvotes: 3