# op:subtract-times - XPath XQuery Reference

Returns the xs:dayTimeDuration that corresponds to the elapsed time between
            the values of $arg2 and $arg1 treated as times on the same
            date.Defines the semantics of the "-" operator
         when applied to two xs:time values.deterministiccontext-dependentfocus-independentThe function returns the result of the expression:op-subtract-dateTimes(
        fn:dateTime(xs:date('1972-12-31'), $arg1),
        fn:dateTime(xs:date('1972-12-31'), $arg2))Assume that the dynamic context provides an implicit timezone value of
                  -05:00. Assume, also, that the date components of the reference
                  xs:dateTime correspond to "1972-12-31".op:subtract-times(xs:time("11:12:00Z"),
                  xs:time("04:00:00"))xs:dayTimeDuration("PT2H12M")This is obtained by subtracting from the xs:dateTime
                  value {1972, 12, 31, 11, 12, 0, PT0S} the xs:dateTime
                  value {1972, 12, 31, 9, 0, 0, PT0S}.op:subtract-times(xs:time("11:00:00-05:00"),
                  xs:time("21:30:00+05:30"))xs:dayTimeDuration("PT0S")The two xs:dateTime values are {1972, 12, 31, 11,
                     0, 0, -PT5H} and {1972, 12, 31, 21, 30, 0, PT5H30M}. These
                  normalize to {1972, 12, 31, 16, 0, 0, PT0S} and {1972, 12, 31,
                     16, 0, 0, PT0S}. op:subtract-times(xs:time("17:00:00-06:00"),
                  xs:time("08:00:00+09:00"))xs:dayTimeDuration("P1D")The two normalized xs:dateTime values are {1972,
                     12, 31, 23, 0, 0, PT0S} and {1972, 12, 30, 23, 0, 0,
                  PT0S}.op:subtract-times(xs:time("24:00:00"),
                  xs:time("23:59:59"))xs:dayTimeDuration("-PT23H59M59S")The two normalized xs:dateTime values are {1972,
                     12, 31, 0, 0, 0, ()} and {1972, 12, 31, 23, 59, 59.0,
                  ()}.Any other reference date would work equally well.