Calculate how much business time it happens between 2 dates (weeks, days, hours, minutes)

Nicolás Donnelly Kehoe September 1, 2022

Hi,

I'd like to know if you can help me with this: I'm trying to calculate how much business time it happens between 2 dates (weeks, days, hours, minutes), for example:

  • Date A: 2022-08-18 10:00 AM
  • Date B: 2022-08-26 02:30 PM

* BusinessDays (business days are considered to be Monday to Friday, 9am to 6pm)

I need to calculate the business time between Date A and Date B: 1w 1d 4h 30m

 

Thanks in advance!!

1 answer

0 votes
Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 1, 2022

Hi @Nicolás Donnelly Kehoe and welcome to the community!

This can be done with automation, but I'd need further context into how you're planning to use this data.  For example, if you're looking to capture it in a report/dashboard, you'd need to capture the data in a custom field vs sending a communication (comment, slack/teams, email), it could just be in the body of the message. 

Here's a quick example of how it could work (I'm using Now and Due Date):

  • TRIGGER: Field Value Changed (Due Date)
  • ACTION: Add Comment
    • {{now.diff(issue.dueDate).businessDays}}
    • To get hours, mins, seconds, you'd need to do some math against that... Weeks = {{#=}}now.diff(issue.dueDate).businessDays}}/5{{/}}
      Hours = {{#=}}now.diff(issue.dueDate).businessDays}}*8{{/}}
Nicolás Donnelly Kehoe September 1, 2022

Hi @Mark Segall 

Thanks for you response!

I've tried using that function but I think it returns just the number of days between those dates. I believe it doesn't include number of hours, minutes. 

For more context, I'm trying to create an automation to log work when an issue goes from WIP to DONE. 

Thanks again

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 1, 2022

Sorry - Edited my response after.  You'll need to perform some math functions to get the breakdown you're looking for, but it all starts with Date Diff and businessDays

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 1, 2022

Unless someone beats me to it, I'll spend a little time on this later today to try and help with exact math functions.

Nicolás Donnelly Kehoe September 1, 2022

Thanks a lot Mark! I really appreciate your support!

I'll also try to apply what you have shared with me before.

Dan Wade April 12, 2023

Honestly, I added an automation handler and call an webhook with the issue payload. My webhook endpoint calculates the hours, and updates the field. Or, returns that value back.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events