difference (in days) of two dates

G

Guest

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.
 
H

Hans Kesting

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 Kestin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top