-1

The below XQuery code returns:

Duration=3 hour

but I expect:

Duration=03 hour

What am I doing wrong?

{
    let $hour := hours-from-duration(op:subtract-times(xs:time(fn:substring-after('2015-07-31T10:25:00','T')),xs:time(fn:substring-after('2015-07-31T07:15:00','T'))))            
    return
    <FlightDuration> {($hour)}</FlightDuration>
}
showdev
  • 28,454
  • 37
  • 55
  • 73
Sai
  • 17
  • 4

1 Answers1

1

Based on your example, I am guessing that you are using OSB 11 or some earlier version. You could try using fn-bea:format-number. Also, I would avoid using anything under op:* directly.

let $dt1 := xs:dateTime('2015-07-31T10:25:00')
let $dt2 := xs:dateTime('2015-07-31T07:15:00')
let $t1 := xs:time($dt1)
let $t2 := xs:time($dt2)
let $diff := $t1 - $t2
let $hour := hours-from-duration($diff)
return
   <FlightDuration>{fn-bea:format-number($hour, "00")}</FlightDuration>

Evaluates to:

<FlightDuration>03</FlightDuration>
Josh
  • 413
  • 2
  • 7