web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

DateDiff function

(0) ShareShare
ReportReport
Posted on by 390

Hey community, 

I have created a field "Resolution Time" that will be used for calculating the time between a issue created by the client and resolved by the employee using DateDiff(Issue Creation Date, Issue Close Date, TimeUnit.hours). So for e.g. if the issue is resolved in 5 days the resolution time will be 120 hours (5 days*24 hours). The thing is that employee only works for 8 hours a day. So the employee took 40 hours to resolve the issue and not 120 hours. How can I formulate that? 

pastedimage1674112909296v1.png

This formula I have created but it is not working accurately. 

pastedimage1674113026506v2.png

Like in the above case it should give 121 hours and 8 minutes in 24hours a day format and 41 hours and 8  minutes in 8hours a day format but its giving only 121 hours in 24hours a day format and 40.33 in 8hours a day format. Kindly suggest me the accurate formula for doing it. Thank you,

I have the same question (0)
  • Muhammad Anas Naeemi Profile Picture
    390 on at

    You can also suggest me the formula resulting as 5 days 1 hour and 8 minutes for the above given time duration.

  • Suggested answer
    Naveen Ganeshe Profile Picture
    3,397 User Group Leader on at

    Hi Anas,

    You can give it a try:

    DateDiff(IssueCloseDate,IssueCreateDate,TimeUnit.Minutes) / 60 / 8

    It will result in time in days

  • Muhammad Anas Naeemi Profile Picture
    390 on at

    Hey Naveen it is not working. Can you show me code for displaying A days, B hours and C minutes

  • Suggested answer
    Naveen Ganeshe Profile Picture
    3,397 User Group Leader on at

    Here is a c# code. you can convert this

    TimeSpan resolutionTime = issueCloseDate - issueCreationDate;
    
    int totalDays = (int)resolutionTime.TotalDays;
    int workingDays = totalDays - (totalDays/7)*2; 
    int workingHours = workingDays * 8;
    int minutes = resolutionTime.Minutes;

  • Muhammad Anas Naeemi Profile Picture
    390 on at

    Hey everyone, thank you everyone for the response. I have achieved my desired functionality.

  • Naveen Ganeshe Profile Picture
    3,397 User Group Leader on at

    Good to hear that.

  • Suggested answer
    Eiken Profile Picture
    on at

    Hi, 

    You can also create two new calculate field, one is calculate hours and another calculate minutes using DateDiff.

    pastedimage1674207960945v1.png

    Then create a field using formula.

    pastedimage1674208026653v2.png

    pastedimage1674208071210v3.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
iampranjal Profile Picture

iampranjal 41

#2
Martin Dráb Profile Picture

Martin Dráb 38 Most Valuable Professional

#3
Satyam Prakash Profile Picture

Satyam Prakash 35

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans