That function never found its way from the working drafts to the
recommendation.  You can achieve something similar by using the
following (yes, by using the average number of days in a month, which
is fragile and works fine only for large numbers of days, over several
years):

    let $days   := xs:dayTimeDuration("-P3278D") div xs:dayTimeDuration('P1D')
    let $months := $days idiv 30.43684991666667
    return
      $months * xs:yearMonthDuration('P1M')

  Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


On 20 February 2015 at 01:02, William Sawyer wrote:
> I have two dates I am trying to subtract and get a xs:yearMonthDuration.  In
> "0.9-ml" there is a function you can call but in "1.0-ml" the documentation
> says to subtract the dates.  But how do I specify that I want a
> xs:yearMonthDuration instead of a xs:dayTimeDuration.
> MarkLogic Version: 7.0-2.3
>
> Thanks,
> -Will
>
>
> xquery version "1.0-ml";
>
> let $date1 := xs:dateTime(xs:date("2015-03-27"))
> let $date2 := xs:dateTime(xs:date("2024-03-27"))
> let $test := $date1 - $date2
> return $test
> ***************
> xs:dayTimeDuration("-P3288D")
>
>
> xquery version "0.9-ml"
>
> let $date1 := xs:dateTime(xs:date("2015-03-27"))
> let $date2 := xs:dateTime(xs:date("2024-03-27"))
> let $test := fn:subtract-dateTimes-yielding-yearMonthDuration($date1,
> $date2)
> return $test
> **************
> xs:yearMonthDuration("-P8Y11M")
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to