You are viewing limited content. For full access, please sign in.

Question

Question

Time calculation in forms

asked on July 6, 2016

Hi,

Does anyone know if any of the open formula time functions are supported in Laserfiche forms? I am interested in using TIME and TIMEVALUE to work out a time difference between forms fields.  I realise I can do this with jquery or JavaScript but would like to do it without if possible.  It seems that not all supported functions are documented in the online docs so I'm hoping that these functions may be available.  

I have tried =TIMEVALUE("12:00:00") in a forms calculation without success.

many thanks,

1 0

Answer

SELECTED ANSWER
replied on July 7, 2016

Time functions are not support in Forms 10. They will be support with Forms 11 along with new time field.

2 0

Replies

replied on May 19, 2017

Time field is available now in Forms 10.2.1 but are there any functions included that will work right out of the box ? Or still that is a version 11 thing ? Trying to do time difference calculations using the time field and would be nice if there was built in function available.

1 0
replied on August 11, 2017 Show version history

Subtraction of Time field is not supported yet. The reason is Time represent a spot during a day without specifying which day. And the difference between time values is a timespan. If you want to calculate the difference, you can use use two date fields with Show Time checked, set default value for the two date fields to same value, add a CSS class to the date fields called "showtimeonly" then use custom CSS to hide the date input and picker.

.showonlytime .cf-date-field-date{display:none}

And add another time field with calculation of "=Datetime1-Datetime2"

Sample as following:

 

0 0
replied on January 23, 2018

Subtraction of time field is supported since Forms 10.3 with bulit-in calcutions: you can use calculation such as =time2-time1 or =SUB(time2,time1) to get the difference between two time fields:

1 0
replied on May 2, 2018 Show version history

Are there built-in calculations to take, for example, the "Time Difference" field and convert it to a number field? For example, I worked from 8:00 to 9:30 which is 1.5 hours but the time different field above would display as 1:30:00. How can I make that conversion so I can actually perform timesheet functions on hours later?

 

1 0
replied on May 3, 2018

Does this work with fields in a collection? I can't seem to get it to work.

0 0
replied on May 3, 2018

I cannot get this calculation to work with a table or a collection. :( Very important for a timesheet where you could have a variable number of entries.

0 0
replied on May 8, 2018 Show version history

Did you guys delete some replies on this thread? I thought there was some other replies here.

 

replied on July 3, 2019

Hi Elexis,

Any luck with this one?  I am trying to do the same thing but its not working for me either.

Thank you,

Manny

1 0
replied on July 3, 2019

Sure. I'll share what I wound up going with:

 

IE. Shift is 8:00 to 5:00. The user would enter 0800 and 0500 in the fields and the calc would work with that best.

$(document).ready(function () {
  
  $('.cf-collection-block').on('blur', 'input', function(){
  //alert('ok cool');
    calcHours();
  });

function calcHours() {
  var beginTime = 0;
  var endTime = 0;
  var pauseTime = 0;
  var grandTotal = 0;
  var totalTime = 0; 

  $('.cf-collection-block ul').each(function () {
    beginTime = moment($(this).find('.beginTime input').val(), 'HHmm');
    endTime = moment($(this).find('.endTime input').val(), 'HHmm');
    pauseTime = parseNumber($(this).find('.pauseTime input').val());
    totalTime = endTime.diff(beginTime, 'hours', true) - pauseTime;
    $(this).find('.totalTime input').change();
    
    $(this).find('.totalTime input').val(totalTime.toFixed(2));
    grandTotal += totalTime;
  });  
  
  $('.grandTotal input').val(grandTotal);       

}
  function parseNumber(n){ 
    var f = parseFloat(n);
    return isNaN(f)?0:f;
  }

});

I'd be glad to share the form, but I can't attach an XML or ZIP. Just leave me an email address, and I'll send it to ya.

1 0
replied on February 4, 2020

Hi

What if I had a table with a date and time selector:

And I wanted beginTime - endTime into the field next to it?

So 2020-02-05 10:00 AM - 2020-02-06 16:30 = x

I've been fiddling around with what you guys said above but not winning.

Thanks in advance

Regards.

0 0
replied on February 5, 2020

For date time fields inside table, you can use formula as following to get the time in hours.

=Sub(INDEX(Table.End_Time,ROW()),INDEX(Table.Start_Time,ROW()))*24

3 0
replied on March 24, 2020

Hi there!

What would be the formula if I wanted to add the total time of hours worked when entering different entries in the table?  Thanks!

Screen Shot 2020-03-24 at 9.12.46 AM.png
0 0
replied on March 25, 2020

You can use “=SUM(Table.HoursWorked)"

1 0
replied on July 8, 2016

Thanks Xiuhong

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.