alle3x
alle3x

Reputation: 495

Day difference between two dates in XSLT version 2.

Is there a easy way I can get how many days is the difference between two dates in XSLT.

Upvotes: 1

Views: 414

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167571

You can subtract one xs:date from another one and then you get an xs:dayTimeDuration of which you can extract components e.g. xs:date('2015-06-11') - xs:date('2015-06-01') gives an xs:dayTimeDuration P10D and you can then call http://www.w3.org/TR/xquery-operators/#func-days-from-duration e.g. days-from-duration(xs:date('2015-06-11') - xs:date('2015-06-01')) which gives 10.

Upvotes: 1

Related Questions