Rank: Newbie
Joined: 7/2/2010 Posts: 6
|
I have to express the difference of two dates in months.
Subtracting two dates with an =AutoCalc always returns an xs:duration value that is given in days e.g. P389D. Applying xs:yearMonthDuration() gets me P0M. Instead I expected to get a yearMonthDuration() in order to be able to calculate the total number of months applying a straightforward algorithm (in this case the result would be 13 as rounding would be used).
So: Why do I get a result like P389D instead of P1Y0M25D? And how can I get a proper xs:yearMonthDuration?
|
Rank: Advanced Member
Joined: 12/13/2005 Posts: 2,856 Location: Mauritius
|
All answers to your questions can be found in W3C spec. In order to resolve your particular issue - you can simply extract amount of days and divide it by whatever number you believe a month lasts (the variety of days in month is probably THE reason why there is no conversion). Alternatively, you can extract years and months from your original dates and make calc directly.
|