Click here to Skip to main content
15,921,210 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm having a table in sql with date in datetime format. I want to select the data from this table to a gridview. But instead of the date '2012-05-30 00:00:00' in the sql table, it is displayed as '2012-05-30 AM 12:00:00' in the gridview so that i'm not able to update the table based on the date. What can I do for this?
Posted

please try below code in your grid column

<asp:boundfield datafield="Fromdate" headertext="Date" dataformatstring="{0:MM/dd/yyyy}" xmlns:asp="#unknown">
 
Share this answer
 
You do like this
string str = "2012-05-30 AM 12:00:00";
		string date = str.Substring(0, 10);
		DateTime visitDate = DateTime.Parse(date);
		Label2.Text = visitDate.ToString("dd-MMM-yyyy");//30-May-2012 
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900