Expand my Community achievements bar.

calculating times in 15 minute increments

Avatar

Former Community Member

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

12 Replies

Avatar

Former Community Member

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

Avatar

Former Community Member

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

Avatar

Former Community Member

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

Avatar

Former Community Member

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?

Avatar

Former Community Member

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

Avatar

Former Community Member

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 ... ])

Avatar

Former Community Member

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)

Avatar

Former Community Member

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

Avatar

Former Community Member

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

Avatar

Former Community Member

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