Support Forum

Ask questions and get help from MobileTogether experts.
MobileTogether Product Information
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
View
Go to last post Go to first unread
jwatt222  
#1 Posted : Monday, June 6, 2016 6:54:52 AM(UTC)
jwatt222

Rank: Advanced Member

Groups: Registered
Joined: 5/23/2016(UTC)
Posts: 129
United States
Location: Virginia

Thanks: 20 times
I am working with hours of service for truck drivers and adding hours and minutes.

I am trying to extract the first part of say 35.57 to get just the 35, In another instance I want to get just the .35 Been playing with this for a couple of days now and have searched numerous forums and such online but can't find any xpath function to do this. I've tried rounding up or down, and using the floor and ceiling functions.

I was able to get the .35 using this but it doesn't seem to be accurate in all cases.

$PERSISTENT/Root/CurrentLoad/PastLoads/HOSUInitial - floor($PERSISTENT/Root/CurrentLoad/PastLoads/HOSUInitial)

Can't seem to get the 35

Is it possible to accurately do this? If so Can you help. Other than not being able to connect my phone to the server or to the designer this is the very last thing I need to be complete with my app.

I'm hoping that you can help.

Thanks,
bbv  
#2 Posted : Monday, June 6, 2016 8:59:38 AM(UTC)
bbv

Rank: Administration

Groups: Registered, Administrators
Joined: 7/21/2014(UTC)
Posts: 498

Was thanked: 88 time(s) in 88 post(s)
Your approach was correct, there is a small modification required to your statement:

$PERSISTENT/Root/CurrentLoad/PastLoads/HOSUInitial - xs:decimal(floor($PERSISTENT/Root/CurrentLoad/PastLoads/HOSUInitial))

xs:decimal guarantees precise handling of the digits after comma.

P.S. just in case you want to fully understand what happens: function floor returns a double when applied to a node as defined by the XPath standard. Every further arithmetic calculations with one of the operands being double becomes double by itself. double type encodes digits after comma so that only in specific cases they are equal to the source, in most cases it is a close approximation. By converting floor result to xs:decimal you make the rest of the statement being calculated as xs:decimal with the expected result.
jwatt222  
#3 Posted : Monday, June 6, 2016 10:40:20 AM(UTC)
jwatt222

Rank: Advanced Member

Groups: Registered
Joined: 5/23/2016(UTC)
Posts: 129
United States
Location: Virginia

Thanks: 20 times
Thanks to your help, I'll learn. It seems though I'm learning French or something. Thanks for taking the time to explain. I've been up all night and there are two things stopping me from moving forward with my app. This and the fact that I still can't get my phone to connect to the server or the designer.

This gets me the .35, but how do I get the numbers to the left of the decimal?

For example converting 27.35 to get just the 27
bbv  
#4 Posted : Monday, June 6, 2016 1:30:39 PM(UTC)
bbv

Rank: Administration

Groups: Registered, Administrators
Joined: 7/21/2014(UTC)
Posts: 498

Was thanked: 88 time(s) in 88 post(s)
Sorry, I thought it was clear. Just use the floor function.

P.S. With or without xs:decimal doesn't matter in this case, because double and decimal are equally fine for digits before comma
thanks 1 user thanked bbv for this useful post.
jwatt222 on 6/6/2016(UTC)
jwatt222  
#5 Posted : Monday, June 6, 2016 7:08:31 PM(UTC)
jwatt222

Rank: Advanced Member

Groups: Registered
Joined: 5/23/2016(UTC)
Posts: 129
United States
Location: Virginia

Thanks: 20 times
Thanks. My app is finished. Now to try and fix the connection problem. It seems that something might be missing from my incoming connections protocol. Recently upgraded to Windows 10. It appears that this is common after installing Windows 10. I'll have to research to figure out how to resolve that so that I can test the app on a phone. Then I'm ready to go live.

I've tried everything and know that I couldn't have completed my app without you and Mobile Together Designer. So thankful that I found you.

Thanks for all the patience and help.
bbv  
#6 Posted : Tuesday, June 7, 2016 8:48:53 AM(UTC)
bbv

Rank: Administration

Groups: Registered, Administrators
Joined: 7/21/2014(UTC)
Posts: 498

Was thanked: 88 time(s) in 88 post(s)
You are very welcome. Feel free to come back if you get more questions.
Users browsing this topic
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.