79701485

Date: 2025-07-15 02:09:46
Score: 1
Natty:
Report link

Solution 1:

foreach (DataRow dr in dt_appointments.Rows)
{
    dr["Start"] = Convert.ToDateTime(dr["Start"]).ToLocalTime().ToString("g");
    dr["End"] = Convert.ToDateTime(dr["End"]).ToLocalTime().ToString("g");
}

Solution 2:


dgv_appointments.DataSource = dt_appointments; 

dgv_appointments.Columns["End"].DefaultCellStyle.Format = "g"; 

dgv_appointments.Columns["Start"].DefaultCellStyle.Format = "g"; 

For your reference, all date and time format strings are available here:
https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Dev With MJ