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

Notifications

Announcements

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)
  • ashlega Profile Picture
    34,477 on at

    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.

  • Abhiram Thulasi Profile Picture
    2 on at

    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

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    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.

  • Community Member Profile Picture
    on at

    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

       */

    }

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…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ZS-27011425-0 Profile Picture

ZS-27011425-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans