Representa un intervalo de tiempo. Un objeto TimeSpan representa un intervalo de tiempo (duración de tiempo o tiempo transcurrido) que se mide como un número positivo o negativo de días, horas, minutos, segundos y fracciones de segundo.
Ejemplo:
protected void Button1_Click(object sender, EventArgs e)
{
TimeSpan tspan;
DateTime inicio;
DateTime final;
inicio = DateTime.Now;
//codigo de proceso o consulta
final = DateTime.Now;
tspan = final.Subtract(inicio).Duration();
Label1.Text = tspan.Duration().ToString();
Label2.Text = " Minutos: " + tspan.Minutes.ToString();
Label3.Text = " Segundos: " + tspan.Seconds.ToString();
}
Excelente aporte, gracias!!
ResponderBorrar