• 0

# Hours And Minutes - Parsing As A String?

## Question

Hello,

I have a form that collects two times on a 24 hour time format. Like a start and end time. Let's say 14:00 and 16:30. I need calculate the hours and minutes duration and output the hours in one column, and the minutes in another. So in this case, the hours column would have 2, and the minutes would be 30. Also, it needs to handle when the time extends onto another day, such as start at 20:00 and end time is 00:45. In this case, the hours columns needs to output 4, and the minutes would be 45.

Any help is greatly appreciated.

## Recommended Posts

• 0
On 10/25/2022 at 6:25 PM, zacharj13 said:

Hello,

I have a form that collects two times on a 24 hour time format. Like a start and end time. Let's say 14:00 and 16:30. I need calculate the hours and minutes duration and output the hours in one column, and the minutes in another. So in this case, the hours column would have 2, and the minutes would be 30. Also, it needs to handle when the time extends onto another day, such as start at 20:00 and end time is 00:45. In this case, the hours columns needs to output 4, and the minutes would be 45.

Any help is greatly appreciated.

Hello @zacharj13,

You can use this formula to get the hours:

`DATEDIFF(s, [@field:StartTime],[@field:EndTime])/3600`

And this formula for minutes:

`DATEDIFF(s, [@field:StartTime], [@field:EndTime])%3600/60`

You can check this for reference:

##### Share on other sites

• 0
10 hours ago, cheonsa said:

Hello @zacharj13,

You can use this formula to get the hours:

`DATEDIFF(s, [@field:StartTime],[@field:EndTime])/3600`

And this formula for minutes:

`DATEDIFF(s, [@field:StartTime], [@field:EndTime])%3600/60`

You can check this for reference:

Thanks, does the DATEDIFF data type have to be date/time on the form? How can the input field be setup to input time only, not calendar day, month, year, etc

##### Share on other sites

• 0

Hello @zacharj13, you can use text data type as well for the datediff. An example for this is a text field that has the calendar popup enabled.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.