Click here to Skip to main content
15,891,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am displaying date in one of the column in my gridview . I have binded my gridview programmatically i.e using code behind .
The corresponding column data type in the database is Date , but still it displays 11/23/2013 12:00:00 AM . If I execute the procedure in the database it
shows 11/23/2013 . But in the gridview it shows time too even though the time is not there in the database.
Please help .
Posted

In your select query cast the date,
example :
select convert(varchar,datecolumn,105) from table.
note: you can change the 105 to other number to get in different date format (105 will give you dd-MM-yyyy format).
 
Share this answer
 
how-to-set-date-format-in-gridview.html[^]

Check this and format according to your need..
 
Share this answer
 
when we fetch the data from database the data will be returned as object. So before binding to the grid u need to convert the value to string and specify the date format and then bind the data like Convert.ToDateTime(data).ToString("dd/mm/yyyy")
 
Share this answer
 

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