Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi Everyone Hope you are fine...
I am building a windows application and face a problem into it. when i populate the DataGridView the Date format show me like "12/12/2017 12:00:00" along with time what i want to do here is i want to display only date in "DD/mm/yyyy" format except time what i will have to do kindly post some suggestions... thankx in advance

What I have tried:

the following code do not work for me:

dataGrid.Columns[2].DefaultCellStyle.Format = "MM/dd/yyyy"
Posted
Updated 16-Mar-17 0:26am
Comments
Graeme_Grant 16-Mar-17 6:15am    
Google Search has a ton of answers for you: How to export datatable to xls file in C#[^]
Muhammd Aamir 16-Mar-17 6:18am    
i have tried a lot nothing goes fine
Graeme_Grant 16-Mar-17 6:19am    
Did you click on the link provided? I had a look and there are valid answers. Would you like me to copy and paste one for you?
Muhammd Aamir 16-Mar-17 6:21am    
ya please do
Graeme_Grant 16-Mar-17 6:21am    

1 solution

When I try that with a dataGridView, it works fine, provided the date information I have loaded into the DGV data source is actually a DateTime value: if it's a string representation of a date, then it can't do anything with it.

Check your data source: if it's a DB, make sure that the source column is DATE or DATETIME and that you don't format it with a CONVERT when you retrieve the information.
 
Share this answer
 
Comments
Muhammd Aamir 16-Mar-17 6:28am    
thanks sir i appreciate your knowledge...
OriginalGriff 16-Mar-17 6:36am    
You're welcome!

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