Skip to main content
Question

Calculating Hours As Percentage Of Day

  • January 30, 2020
  • 4 replies
  • 19 views

With the help of a number of posts on the forums, I've taken a large dataset and been able to evaluate the total time, within a range of days, pool cars have been used. What I'm now struggling with is to calculate the hours used as a percentage of a "working day"

eg;

Car One used for 04:20:00 hours, what percentage use is this against a working day of 07:00:00?

 

Do I need to calculate this out in seconds and convert back or is there another way?

 

Thank you.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • January 30, 2020

I wrote out the calculation for you ( as I could not find a transformer to do so).

Was not too hard.

Hope this helps.


david_r
Celebrity
  • 8392 replies
  • January 30, 2020

Pretty much whatever the solution, it would end up being converted to seconds somewhere along the way.

Try to create a new attribute with the following formula in the arithmetic editor (substituting "usage" and "workday" with your own attribute names of course):

@DateTimeParse("@Value(usage)",%H:%M:%S)*100.0/@DateTimeParse("@Value(workday)",%H:%M:%S)

With your example it returns 60.


  • Author
  • 1 reply
  • January 30, 2020

@erik_jan & @david_r , thank you both for the replies. I did work through a solution after posting this morning, but will try both your answers. (I'm a complete FME newbie but love what it does).

 

I'm now looking at taking results from another dataset in order to add them to this data.

 

 

I shall post a grab of what I put together.

mark2atsafe
Safer
Forum|alt.badge.img+56
  • Safer
  • 2554 replies
  • January 31, 2020

I put a solution in the Question of the Week thread.

Basically a DateTimeCalculator should do most of what you need by simply assuming the work day runs on 000000 to 070000: