Hi, misters which the best method for get the difference (in days) of two dates. The hour (hh:mm) don't mind, would be 00:00 for all dates. 1.) fechaUno.Substract(fechaDos).Days 2.) int desplazamientoFechaActual = fechaLaborable.DayOfYear - fechaActual.DayOfYear; 3.) DateTime now = DateTime.Now; DateTime seed = Convert.ToDateTime("2006/01/01"); TimeSpan diff = now - seed; int result = diff.TotalDays; 4.) Another ?? Any help about it ? Thanks in advance. Greetings. -- http://www.alhambra-eidos.es/web2005/index.html www.kiquenet.net www.trabajobasura.com/solusoft
> Hi, misters > > which the best method for get the difference (in days) of two dates. > The hour (hh:mm) don't mind, would be 00:00 for all dates. > > 1.) > fechaUno.Substract(fechaDos).Days > 2.) > > int desplazamientoFechaActual = fechaLaborable.DayOfYear - > fechaActual.DayOfYear; > > 3.) DateTime now = DateTime.Now; > DateTime seed = Convert.ToDateTime("2006/01/01"); > TimeSpan diff = now - seed; > int result = diff.TotalDays; > 4.) Another ?? > > Any help about it ? Thanks in advance. Greetings. > method 2 gives a wrong answer when the dates are in different years. methods 1 & 3 return the same results (when you use the same dates) Hans Kesting