Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: Datediff in XPath [Thread Next] Re: Datediff in XPathTo: NULL Date: 2/15/2009 7:38:00 PM On Feb 14, 2:05=A0am, Martin Honnen <mahotr...@yahoo.de> wrote: > 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. > =A0 =A0current-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. > =A0 =A0days-from-duration(current-date() - xs:date('1956-12-07')) idiv 36= 5 > should give 52. > Thanks Martin I'll try that out. | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
