C#C
C#3y ago
yumo

❔ date difference

Quick question, why is this not giving me any result on my column resultado?

horaInicio is nvarchar(max)
horaFim nvarchar(max)
resultado nvarchar(max)

// get the value of the "horaInicio" column
DateTime horaInicio = (DateTime)row.Cells["horaInicio"].Value;

// get the value of the "horaFim" column
DateTime horaFim = (DateTime)row.Cells["horaFim"].Value;

// calculate the duration between the two times
TimeSpan duration = horaFim - horaInicio;

// set the value of the "resultado" column to the duration in hours
row.Cells["resultado"].Value = duration.TotalHours;
Was this page helpful?