years,months,days

  • Thread starter Thread starter Jose
  • Start date Start date
J

Jose

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

Thanks a lot.
 
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.
 
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.
 
or you could use a real function like DateDiff right?

who the hell changes a function like DateDiff??

-Aaron
 
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.
 
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
 
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. :)
 
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.
 
Back
Top