473,473 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

subtracting dates

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
9 3213
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
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
* "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
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
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
* "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
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
* "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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jesse O | last post by:
I have two date fields, start_date and end_date. I'd like to subtract the two dates, and come up with a number (the number of difference between the two dates). What function is there to do...
2
by: Eddie | last post by:
When I subtract dates, I can't figure out what I get out. I first I thought it was in seconds, but that's not it. Then I figured maybe HHMMSS, but that does not seem to be it too. How can I...
6
by: Brian Henry | last post by:
How would i take two dates startdate and enddate and subtract startdate from enddate to figure the number of days between the two? thanks
8
by: Ifollowhim | last post by:
I have a (installation) date in a table that I put in manually. It is the date we want to complete a job. In a form that uses data from that table I want to add a text box that is bound to the...
4
by: David S. Alexander | last post by:
How can I do simple subtraction in an XSLT. I want to read a few attribute values from an XML document, calculate their difference, and transform that value to an attribute in the XML output...
31
by: Spiro Trikaliotis | last post by:
Hello, I have a question regarding subtracting a pointer from another one. Assume I have two pointers p1 and p2, which both point to a memory area obtained with malloc(). Assume p1 = p2 + some...
1
by: netboss | last post by:
i have two dates, last weeks date and an experation date. i need to find the difference between the two in DAYS. does anyone have any advice
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.