1

so this is the xml node i am creating for Quickbooks. Sending over duration (its time kinda thingie)

XmlElement duration2 = inputXmlDoc.CreateElement("Duration");
timeTrackingAdd2.AppendChild(duration2);
duration2.InnerText = "PT0H14M0S"

as per the format, i am assuming it should convert this into 0.14 in Quickbooks. But the conversion is different from my assumption

You can see the changed value in the Image Below: 0.23 this is the image of the data transferred to QB. It converted the duration to 0.23. What could be the formula here?

Some multiple tries with different values:

PT0H1M0S 1 converts to 0.02
PT0H10M0S 10 converts to 0.17
PT0H14M0S 14 converts to 0.23
PT0H30M0S 30 converts to 0.50

which approach will help me transfer the duration from my Web Application to Quickbooks converting it into accurate duration?

ARr0w
  • 1,701
  • 15
  • 31

1 Answers1

2

According to your edited example and the standard, it converts those inputs to decimal.

1 hour converts to 1, thus:
1 minute = 1/60 = 0.0166667 which rounds up to 0.02.
10 minutes = 10/60 = 0.166667 which rounds up to 0.17.
14 minutes = 14/60 = 0.23333 which rounds up to 0.23.
30 minutes = 30/60 = 0.50.
Héctor Álvarez
  • 494
  • 3
  • 18
  • Yeah, i have already tried `PT1H0M0S` and yes the output is `1.00`. But the variance occur in `0M` or `00M` which it shouldn't. As i have values in Decimals like: `0.14`, `0.40` – ARr0w Apr 12 '18 at 11:43
  • Try to do `PT0H01M0S` and tell us if you get the same as the non-zero-padded version. – Héctor Álvarez Apr 12 '18 at 13:14
  • just did `PT0H01M0S` converted to `0.02` – ARr0w Apr 12 '18 at 13:31
  • Come to think of it, the result was fine from the start, **1/60 = 0.0166667, which rounds up to 0.02**. – Héctor Álvarez Apr 12 '18 at 13:49
  • yeah, So you are proposing that i should multiply the exact value `0.14` with `60` - `e.g:0.14x60=840` ? that it shows `0.14` there too. – ARr0w Apr 12 '18 at 14:15
  • I'm suggesting the output value is the decimal representation of that field, right now it's in hours. E.g. 2 hours and 30 minutes = 2.5 (hours), taking that into account you can convert to any unit you want (value * 60 will yield minutes, for example). – Héctor Álvarez Apr 12 '18 at 14:21