Getting time difference

Viewing 10 reply threads
  • Author
    Posts
  • August 27, 2019 at 7:44 PM #36550

    john cesta
    Participant

    How do I calculate endTime-startTime in hours and minutes

    August 27, 2019 at 8:13 PM #36552

    Sam Moffatt
    Participant

    Try out the attached in a calc field. I really wish copy and paste worked better on the Mac for calc fields.

    HOURS gives you the difference between two fields in hours with fractional overflow. So we get the hours value first, get the FLOOR value for it and print that out.

    The next step is to get rid of the whole numbers and have only the fractional value, so we use HOURS again with the floor and take it away from the actual value then we multiply that by 60 to get it to minutes and then get the FLOOR of it to remove the fractional values again.

    Attachments:
    You must be logged in to view attached files.
    August 27, 2019 at 9:49 PM #36563

    Brendan
    Keymaster

    An alternative approach would be to create a formula like:

    [End Date] - [Start Date]

    The result will be the number of seconds between the start date and the end date.

    Then set the Number Format property on the Calculation field to HH:MM and Tap Forms will display the result as a duration in hours and minutes. There are other ways to format the duration too, such as hrs, mins or HH:MM:SS, etc.

    August 28, 2019 at 12:21 AM #36566

    Sam Moffatt
    Participant

    That’s a much more elegant approach, I figured there had to be a better way after I wrote it all up.

    August 29, 2019 at 5:02 AM #36585

    john cesta
    Participant

    Thanks to you both.

    I tried to get a total of the meeting time using a calculation summary but it displays a large negative number. Is there a way to add these meeting times?

    Trying to getting a total summary of meeting times by using a weekly filter.

    August 29, 2019 at 12:06 PM #36592

    Brendan
    Keymaster

    Hi John,

    When you set the Number Format to HH:MM on your Calculation field (assuming you’re returning a Number value), then when you set the Calculation Summary option to Total on your Calculation field, Tap Forms will display the results properly in HH:MM format.

    Not sure why you’re getting negative numbers unless your formula has the subtraction backwards.

    August 29, 2019 at 7:44 PM #36601

    john cesta
    Participant

    Perhaps it’s because my start and end time are

    DateTime fields.

    While the calculation per record works the summary doesn’t.

    When I make two new start and end times specifically as time fields it works and the summary as well.

    August 29, 2019 at 8:08 PM #36603

    Sam Moffatt
    Participant

    I have date time fields and it works ok for me. Here’s a quick screenshot of the settings.

    Time Diff Easy is [End] - [Start] set to number format with the number formatted as Time (HH:MM).

    Attachments:
    You must be logged in to view attached files.
    August 29, 2019 at 8:43 PM #36606

    john cesta
    Participant

    But does the summary calculation work?

    August 29, 2019 at 10:49 PM #36608

    Sam Moffatt
    Participant

    Seems to unless I’m looking at the wrong item.

    Attachments:
    You must be logged in to view attached files.
    August 30, 2019 at 6:14 AM #36627

    john cesta
    Participant

    Huh, I’ll set up another isolated test. I’m on iPad mini.

    When I tried that I received a big negative number. But let me try it again.

    I changed my production form to a separate date and time for meeting start and end.

Viewing 10 reply threads

You must be logged in to reply to this topic.