I have a DateTime and I need to subtract hours from one column to the other. For example, I want to subtract 12:45:00 - 12:25:00
and have the result 20
.
This is the code I'm using
for (int i=0; i<n; i++)
{
DateTime fecha1 = Convert.ToDateTime(inicio[i].ToString("HH:mm:ss"));
DateTime fecha2 = Convert.ToDateTime(arrayhrllegada[i].ToString("HH:mm:ss"));
//var duration = Math.Round(fecha1 - fecha2, 1);
double horas = Math.Round(fecha2.Subtract(fecha1).TotalMinutes,1);
dataGridView1.Rows[i].Cells[7].Value = horas.ToString();
}
It's Start minus Arrival and the result is Wait Time