Skip to main content

Notifications

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 386

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,

  • Suggested answer
    Eiken Profile Picture
    on at
    RE: DateDiff function

    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

  • Naveen Ganeshe Profile Picture
    3,393 User Group Leader on at
    RE: DateDiff function

    Good to hear that.

  • Muhammad Anas Naeemi Profile Picture
    386 on at
    RE: DateDiff function

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

  • Suggested answer
    Naveen Ganeshe Profile Picture
    3,393 User Group Leader on at
    RE: DateDiff function

    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
    386 on at
    RE: DateDiff function

    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,393 User Group Leader on at
    RE: DateDiff function

    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
    386 on at
    RE: DateDiff function

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

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Product updates

Dynamics 365 release plans