cancel
Showing results for
Did you mean:
Workflow Hero

## Time calculation issue when using "dateAddHours"

In my gut, I feel I should know how to fix this.  Alas...I cannot.  I am working on a time-off request form for one of our managers and we are trying to come up with "creative" ways to get around not having a business days/hours function available to us.  Currently, I'm trying out a date calculation for single day requests where someone enters the date and time they want off, then adds the number of hours off in the next field. My calculated value says "add hours to this date/time to get the end time" (at least that's what I want it to say).  What I am finding, though, is that it works great, but with whole numbers only. If someone wants 2.5 hours off, it only calculates the 2 hours and does not include the additional 30 minutes.

My formula:

Results:

My first question: "What am I doing wrong?".  Second question: "How do I fix this?"

Thank you in advance for your brain power during a holiday week!

Tags (2)
8 Replies
Workflow Hero

## Re: Time calculation issue when using "dateAddHours"

is there a date add minutes function?

You may have to do both?

Workflow Hero

## Re: Time calculation issue when using "dateAddHours"

the function adds only whole number of hours by design, see documentation

you will have to add hours and minutes separately as Cassy Freeman‌ suggests.

Workflow Hero

## Re: Time calculation issue when using "dateAddHours"

Thank you both!!  Now...can either of you help with determining what the formula should look like?  I separated the # of hours into 2 fields (# hrs and #mins).  I'm coming up empty with each attempt to get a formula that brings everything together.  I've just completely confused myself into almost giving up!!

Workflow Hero

## Re: Time calculation issue when using "dateAddHours"

Whyt not convert your 2.5 Hours to Minutes (2.5*60=150min) and then use the DateAddMinutes Function.

My Calculated Field Formula:  formatDate(dateAddMinutes(Date,sum(Hours*60)),"MM/dd/yyyy hh:mm tt")

Workflow Hero

## Re: Time calculation issue when using "dateAddHours"

have you tried formula like

``dateAddMinutes(dateAddHours(RequestBeginSingleControl,HoursToAdd),MinutesToAdd)‍``
Workflow Hero

## Re: Time calculation issue when using "dateAddHours"

this approach have 2 drawbacks...

1. it forces users to convert minutes from 1/60 system to 1/100 system. for quarters or half-an-hours it might be straightforward.  but do you know by head decimal number to type in for a value like 2:05?
2. such a calculation is (might be) inaccurate, just because of above mentioned conversion.
Workflow Hero

## Re: Time calculation issue when using "dateAddHours"

While I hear and acknowledge your argument, I do not see any company policy allowing it's employees to apply for 5min leave, generally there is a standard which allows for half hours but not random amounts of minutes (I could be wrong but unlikely), I would instead add validation on the field to not allow random minutes. Imagine the nightmare random amounts of minutes would create for Payroll.

Workflow Hero

## Re: Time calculation issue when using "dateAddHours"

No problem if decimal values fit your needs

I just wanted to point out that in some scenarios one need to be careful