Jump to content
  • 0

Hours And Minutes - Parsing As A String?


zacharj13

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. 

Link to comment
Share on other sites

3 answers to this question

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:

https://stackoverflow.com/questions/13577898/sql-time-difference-between-two-dates-result-in-hhmmss

Link to comment
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:

https://stackoverflow.com/questions/13577898/sql-time-difference-between-two-dates-result-in-hhmmss

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

Link to comment
Share on other sites

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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...