years,months,days

J

Jose

Exists a function that determined between two dates the years,months and
days?

Thanks a lot.
 
C

Chris Dunaway

Scott said:
dim x as date = someDate.subtract(someOtherDate)

The Subtract method on the DateTime structure, when passed another
DateTime, returns a Timespan object and not a DateTime object.

Dim ts As TimeSpan = someDate.Subtract(someOtherDate)

Then you can get the years, months, and days properties from the
TimeSpan.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Chris said:
The Subtract method on the DateTime structure, when passed another
DateTime, returns a Timespan object and not a DateTime object.

Dim ts As TimeSpan = someDate.Subtract(someOtherDate)

Then you can get the years, months, and days properties from the
TimeSpan.

Actually, you can only get the value as days.

As the timespan doesn't contain a starting and ending time, there is no
way to determine the exact length in months and years.
 
A

aaron.kempf

or you could use a real function like DateDiff right?

who the hell changes a function like DateDiff??

-Aaron
 
C

Chris Dunaway

Göran Andersson said:
Actually, you can only get the value as days.

I stand corrected. But when you subtract a date from another date, it
returns a Timespan and not a date.
 
C

Cor Ligthert [MVP]

Jose,

In my idea does this never work as measuring system. Somehow I thought it is
not possible with the Gregorian Calender, every month can have a different
length you know, not to talk about leap years. Therefore it is not such a
good measuring system.

Therefore
Date - Date represented as year, months, will will give a total other
result in by instance days as you use another startdate and add your
measured result.

(Years, weeks, days) or (years, days) will do a better job.
Although the leap year problem sustains..

That is the reason that some people want to use this kind of calendars.

http://en.wikipedia.org/wiki/Positivist_Calendar

But just my thought.

Cor
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Chris said:
I stand corrected. But when you subtract a date from another date, it
returns a Timespan and not a date.

Yes. If you read my next sentence you see that I am referring to the
TimeSpan structure. That implies that I concur with your observation. :)
 
C

Chris Dunaway

Göran Andersson said:
Yes. If you read my next sentence you see that I am referring to the
TimeSpan structure. That implies that I concur with your observation. :)

My mistake, I was actually replying to Scott M.'s message.
 

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