calculating times in 15 minute increments | Community
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 16, 2013 2:20 PM UTC

Thanks for responding. It’s a bit too much for me also!!

Translate
Jono_Moore
Level 10
Sep 11, 2013 9:46 PM UTC
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
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 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 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 7:55 PM UTC

I’m sorry, you lost me!

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: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: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