435,301 Members | 1,766 Online
Need help? Post your question and get tips & solutions from a community of 435,301 IT Pros & Developers. It's quick & easy.

# years,months,days

 P: n/a Exists a function that determined between two dates the years,months and days? Thanks a lot. Jun 3 '06 #1
8 Replies

 P: n/a dim x as date = someDate.subtract(someOtherDate) Then format x as desired. "Jose" wrote in message news:ui**************@TK2MSFTNGP04.phx.gbl... Exists a function that determined between two dates the years,months and days? Thanks a lot. Jun 3 '06 #2

 P: n/a Scott M. wrote: 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. Jun 5 '06 #3

 P: n/a Chris Dunaway wrote: Scott M. wrote: 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. 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. Jun 5 '06 #4

 P: n/a or you could use a real function like DateDiff right? who the hell changes a function like DateDiff?? -Aaron Göran Andersson wrote: Chris Dunaway wrote: Scott M. wrote: 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. 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. Jun 5 '06 #5

 P: n/a Göran Andersson wrote: 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. Jun 6 '06 #6

 P: n/a 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 Jun 6 '06 #7

 P: n/a Chris Dunaway wrote: Göran Andersson wrote: 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. 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. :) Jun 6 '06 #8

 P: n/a Göran Andersson wrote: 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. Jun 7 '06 #9

### This discussion thread is closed

Replies have been disabled for this discussion.