subtracting dates

  • Thread starter Thread starter Mike Fellows
  • Start date Start date
M

Mike Fellows

i have 2 dates

one is todays date and the other is a future date

i want to take todays date from ther future date and tell me how many days
difference this is

thanks in advance

Mike Fellows
 
Dim diff as TimeSpan = dateFuture.Subtract(dateToday)
Dim days as Double = diff.TotalDays

/claes
 
Hi Mike,

Do you mean this?

Dim enddate As Date = Now.AddDays(20)
Dim span As TimeSpan = enddate.Subtract(Now)
MessageBox.Show(span.Days.ToString)

Cor
 
* "Mike Fellows said:
i have 2 dates

one is todays date and the other is a future date

i want to take todays date from ther future date and tell me how many days
difference this is

\\\
Dim d1 As Date = #4/4/1999#
Dim d2 As Date = Date.Now
Dim ts As TimeSpan
ts = d2.Subtract(d1)
MsgBox(CStr(Int(ts.TotalDays)))
MsgBox(CStr(DateDiff(DateInterval.Day, d1, d2)))
///
 
Hi Mike,

They are all the same as Claes, however I was doing more messages in one
time so I did not see it. And Herfried seldom looks what answers there are
already he sends.

Nothing to choose

;-(

Cor
 
* "Cor Ligthert said:
They are all the same as Claes, however I was doing more messages in one
time so I did not see it. And Herfried seldom looks what answers there are
already he sends.

Nothing to choose

;-(

Would be great if you had a look at my post. It contains two different
solutions!
 
Herfried,

As forever, sorry I only saw the first.

Please make them next time that simple that even someone as me can
understand that it are two different solutions.

However, you are right, and you know I am someone who has no problem to
admit that.

Sorry again,

:-)

Cor
 
* "Cor Ligthert said:
As forever, sorry I only saw the first.

Please make them next time that simple that even someone as me can
understand that it are two different solutions.

I thought about separating them when typing the post, but then I forgot
to do so and thought that the OP will see that when running the code.
However, you are right, and you know I am someone who has no problem to
admit that.

Sorry again,

No problem... You are not the only one who doesn't see
everything... :-))).
 
dim d1 as DateTime
dim d2 as DateTime
'....
dim ts as TimeSpan
ts=d2.Substract(d1)
Messagebox(ts.Days.ToString())

Ernest
 
Back
Top