I have a date value in the format 04/05/2017 when adding this value to the MS SQL database (column format - date) is 04/05/2017 00:00:00. That is, the amount of time is automatically added, and it is always zeros. How can I get rid of the time display? Thank.
1 answer
Use the ToString() method; If the date and time are displayed somewhere as text, you can convert it like this (regardless of locale): date.ToString("dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture);
- The date is displayed in the table. Where exactly should I add this code, do not tell? - Denis
- Which table? Datagrid? Is it wpf? - klutch1991
- yes DataGridView, this is a Windows Form. - Denis
|
DefaultCellStyle.Format = "yyyy.MM.dd". Links to documentation: Format property, date / time formats. - Alexander Petrov