Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Datediff in XPath >Thread Next - Re: Datediff in XPath Re: Datediff in XPathTo: NULL Date: 2/13/2009 2:06:00 PM nick wrote: > Is there a way to get the difference between 2 dates in XPath? Eg. how > do I calculate age from date of birth? Thanks! XPath 2.0 has support for the xs:date and the xs:dateTime data types and operators on them. So in XPath 2.0 you can do e.g. current-date() - xs:date('1956-12-07') to get a xs:dayTimeDuration. You could then extract the days and divide by 365 to find the years e.g. days-from-duration(current-date() - xs:date('1956-12-07')) idiv 365 should give 52. -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
