IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Subtracting dates Options · View
marcofago
Posted: Monday, August 30, 2010 11:02:31 AM
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?
vlad
Posted: Tuesday, August 31, 2010 8:00:33 AM
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.
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.