Skip to main content
Sep 9, 2013 6:02 PM UTC
Question

calculating times in 15 minute increments

Good Afternoon,

I am making a form where we report how much leave is being used. The leave will be reported in 15 minute increments. (Ex: fifteen minutes = .15; one-half hour = .30; 45 minutes = .45) I need to be able to add these up and have them keep this format of 15 minute increments. Also, I need the display to be a decimal instead of a colon, if possible. (Ex. 3.45 instead of 3:45).

any advice is appreciated!!!

Gene-O

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

12 replies

Sep 10, 2013 4:01 PM UTC

as far as the colon and decimal this can be done under patterns

example

num{zzzz9:99}

but could you give a little more detail Im a little hazy on what your trying to do

The easiest thing may be to break it into 2 fields or three if days

___days   ____hours  ____min

this way you can manipulate the data a little easier depending on your requirements

Sorry if Im no help still a little hazzy on what yoru trying to do as far as summing

are you going to chang the .15 to a .25 for your calculations ?? and then translate them back to 15 min incriments etc....

Translate
Sep 10, 2013 6:22 PM UTC

Thanks so much for trying to help!!

I need to calculate leave taken by an employee in 15 minute intervals.

For example:

1.15 hours of vacation (one hour and fifteen minutes)

+2.30 hours of holiday leave (two hours and thirty minutes)

+ 4.45 hours of sick leave (four hours and forty-five minutes)

= 8.30 hours of total leave taken (eight hours and thirty minutes)

Anything I try has calculated it as:

1.25

2.50

4.75

=8.50

I have to have it formatted in 15 minute increments instead of decimals

Any ideas?

Gene-O

Translate
Sep 10, 2013 7:30 PM UTC

here is an example using 2 textfields (you could hide one or not)

form1.#subform[0].TextField2::calculate - (FormCalc, client)

if ( TextField1.rawValue == 50 )

then

$.rawValue = "30"

endif

you could do that for 15 30 45 00 etc simply reformat it using smoke and mirrors

Translate
Sep 10, 2013 7:40 PM UTC

Thanks again!

But this only works if I am inputting only “25”, “50”, or “75”. Not if I enter numbers with decimals such as “1.25”. Can I use a wildcard to represent the whole number?

Translate
Sep 10, 2013 7:54 PM UTC

use the right and left function to split it into the seperate elements then concat to remerge them

you can use a script object to do this or a hidden field

Translate
Sep 10, 2013 7:55 PM UTC

I’m sorry, you lost me!

Translate
Sep 10, 2013 8:00 PM UTC

take your value and split it into an array

use len to find out how many numbers are in your value

Len(s1)  Returns the number of characters in a given string.

String.length

then using a little math split it using

Left and Right

Left(s1, n1)  Extracts a specified number of characters from a string, starting with the first character on the left.

String.substring(n1, n2)

Right(s1, n1)  Extracts several characters from a given string, beginning with the last character on the right.

String.substring(n1, n2)

when done modifiying the decimal portion of your array as I described earlier then concat them back together

Concat(s1 [, s2... ] )  Returns the concatenation of two or more strings.

String.concat(s1, s2 [, s3 ... ])

Translate
Sep 10, 2013 9:08 PM UTC

here is a formcalc example to get you started

$.rawValue = Left(textField1.rawValue, 5) ////////on TextField2.rawValue

$.rawValue = Len(TextField1.rawValue)

$.rawValue = Right(TextField1.rawValue, 5) ////////on TextField4.rawValue

$.rawValue = concat(TextField2.rawValue, TextField4.rawValue)

Translate
Sep 11, 2013 6:43 PM UTC

I’m so sorry, but I am lost! I have not had any training in scripting and trying to learn on my own….

Translate
Sep 11, 2013 6:46 PM UTC

Also, this seems to want to do traditional math, instead of dealing with 15 minute increments, or am I missing something?

Translate