day-difference between 2 datetimes

?

=?ISO-8859-2?Q?Marcin_Grz=EAbski?=

Hi Daves,

Daves napisa³(a):
hi,
how do I get the difference, in days, between two DateTime classes?

You'll need the TimeSpan.TotalDays.

sample:
TimeSpan ts=dateTime2.Subtract(dateTime1);
double daysDifference=ts.TotalDays.

With regards
Marcin
 
D

Daves

thx, exactly what was needed
Marcin Grzêbski said:
Hi Daves,

Daves napisa³(a):

You'll need the TimeSpan.TotalDays.

sample:
TimeSpan ts=dateTime2.Subtract(dateTime1);
double daysDifference=ts.TotalDays.

With regards
Marcin
 
C

Christof Nordiek

Hi,

instead of
ts = dateTime2.Subtract(dateTime1);

you als could say

ts = dateTime2 - dateTime1;
 
?

=?ISO-8859-2?Q?Marcin_Grz=EAbski?=

Hi Christof,

You're right.
But i'll trying not using the class operators (overload),
since i leave C++ for Java.
:)

Cheers!
Marcin

Christof Nordiek napisa³(a):
 

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

Top