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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Calculate Date Time Difference in Business Hours

(0) ShareShare
ReportReport
Posted on by 2

Hi All,

I have requirement to calculate the time difference (in business hours/minute) between two date time fields in Dynamics 365. I have different business units in my organisation and which is under different time zone. Is there any way that I can get the time difference in business hours ?

Thank you in advance.

Regards,

Abhiram

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Calculate Date Time Difference in Business Hours

    hi try this

    function DOBvalid() {

       var oneDay = 24 * 60 * 60 * 1000;

       var DOB = Xrm.Page.getAttribute("new_dob").getValue();

       var Today = new Date();

       var diffDays = Math.abs((DOB.getTime() - Today.getTime()) / (oneDay));

       alert(diffDays);

       /*var age = DOB

       if (DOB > Today) {

           alert('Date of birth can not be greater than the date today');

           Xrm.Page.getAttribute("new_dob").setValue(null); //set null value

       */

    }

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at
    RE: Calculate Date Time Difference in Business Hours

    Hi Abhiram,

    You could try using a calculated field to calculate the difference between the two date time fields.

    See: mydynamicscrmblog.wordpress.com/.../calculating-difference-between-two-time-fields-in-crm-2015-without-javascripts/

    Or you could create a simple field with floating point number data type and populate the field using javascript.

    See the links below.

    community.dynamics.com/.../239306

    social.microsoft.com/.../calculate-time-difference-between-two-datetime-fields-hoursminsec-in-jscript-ms-crm-2011

    crm.ipiyush.me/calculate-duration-fields-in-dynamics-crm-2011-via-code-javascript-and-c

    Hope this helps.

  • Abhiram Thulasi Profile Picture
    2 on at
    RE: Calculate Date Time Difference in Business Hours

    Hi,

    Thanks for your reply. I have tried to create one plugin for achieving the same by referring the below blog. However if the two dates are in the same day it is returning 0. If you have any  blog/site reference  please share.

    crmmemories.blogspot.ae/.../calculate-working-time-between-two.html

    Regards,

    Abhiram

  • ashlega Profile Picture
    34,477 on at
    RE: Calculate Date Time Difference in Business Hours

    Hi,

     I'm not sure how the calculations would work (and where would you define the business hours per business unit etc).. sounds like you may need a plugin for this kind of calculations.

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…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans