Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi frds,
I save datetimepicker value(26-11-2015) in date field and retrieve this date in datagrid view cell.when i retrieve this fiels it show(26-11-2015 12:00 AM). But i want only in date format. how can i do this.
Thank you
Posted

When you show the date convert it to a format of your choice using ToString which eliminates the time format.

dtDate.ToString("dd-MMyyyy")

c# doesn't have a Date-only type so the time is always going to be there.

https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring(v=vs.100).aspx[^]
 
Share this answer
 
v2
Set the DataGridView Column.DefaultCellStyle.Format to "dd-MM-yyyy" and it will do it all for you.
https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcellstyle.format.aspx[^]
 
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