I have this code storing date time values in data columns:
DataTable apptTable = new DataTable();
apptTable.Columns.Add("Appointment", typeof(DateTime));
apptTable.Columns.Add("Time Scheduled", typeof(DateTime));
This displays the full datetime with milliseconds.
How can I hide the milliseconds?
I've tried passing the datetime as a formatted string like so:
scheduled.ToString("g");
but this only works when the data column is of type string. The only problem with having the column be of type string is that it doesn't sort properly.
I am not trying to format the datetime object itself. I am trying to change how the DateTime is displayed in the DataColumn/Gridview. Even if I format the datetime object to remove milliseconds, it still displays in the table as 00.