By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,688 Members | 1,900 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,688 IT Pros & Developers. It's quick & easy.

subtracting dates

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Dim diff as TimeSpan = dateFuture.Subtract(dateToday)
Dim days as Double = diff.TotalDays

/claes

"Mike Fellows" <mi***************@equityhouse.co.uk> wrote in message
news:tLYsc.12$NF6.4@newsfe2-win...
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

Nov 20 '05 #2

P: n/a
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
Nov 20 '05 #3

P: n/a
* "Mike Fellows" <mi***************@equityhouse.co.uk> scripsit:
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)))
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

P: n/a
Thanks will have a play between the 3 different variations

Regards

Mike

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2h************@uni-berlin.de...
* "Mike Fellows" <mi***************@equityhouse.co.uk> scripsit:
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)))
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #5

P: n/a
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
Nov 20 '05 #6

P: n/a
* "Cor Ligthert" <no**********@planet.nl> scripsit:
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 K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #7

P: n/a
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
Nov 20 '05 #8

P: n/a
* "Cor Ligthert" <no**********@planet.nl> scripsit:
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... :-))).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #9

P: n/a
dim d1 as DateTime
dim d2 as DateTime
'....
dim ts as TimeSpan
ts=d2.Substract(d1)
Messagebox(ts.Days.ToString())

Ernest


"Mike Fellows" <mi***************@equityhouse.co.uk> wrote in message
news:tLYsc.12$NF6.4@newsfe2-win...
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

Nov 20 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.