POWEROBJECTS

718 Washington Ave. N. Suite #101
Minneapolis, MN 55401
View map and all Locations

Send us a message

If you need to calculate the number of days between two dates, then there are a couple of options for you. There is a function called DATEDIFF being released with Microsoft Dynamics CRM Online Update 1 in Spring of 2015. If you have not yet received that update, then this blog will describe how to achieve this with workflow.

tips-and-tricks

In this solution, we will use the native calculation of the duration on an Activity record and copy that duration to the calculated field on the target record.

Note: Experience with creating custom fields, entities, and workflows is required for this solution. Here’s how we do it.

  1. Create the necessary fields to track the dates and the date difference calculation. In this example, we will calculate the number of calendar days an opportunity was openOn opportunity, we will be using an out-of-the-box field called Created on and a custom fields called Sold date. We are also creating a custom field called Sale Cycle to capture the number of days opportunity was open. The calculation we want to make is

    Sold date – Created = Sales cycle.

    We have created the Sales Cycle field with a Data Type of Whole Number and a Format of Duration.

    Calculating the Number of Days Between Two Dates with Workflow

  2. Create a new entity and check the box for ‘Define as an activity entity’ and publish changes. No other fields are required on this record

    Calculating the Number of Days Between Two Dates with Workflow

  3. Create a Workflow for the Opportunity entity using the specifications in the image below

    Calculating the Number of Days Between Two Dates with Workflow

  4. Under Start When, select Record Field Calculating the Number of Days Between Two Dates with Workflo Changes and check Sold Date
  5. Set the Scope to organization so that this workflow runs for entire organization, if applicable
  6. Insert a step into the workflow, to create a Number of Days record and set properties to set the Start Date = Created On and the Due Date = Sold Date

    Calculating the Number of Days Between Two Dates with Workflow

    Calculating the Number of Days Between Two Dates with Workflow

  7. Add a step to the workflow to update the Sales Cycle field on the Opportunity with the Scheduled Duration field on the Number of Days record

    Calculating the Number of Days Between Two Dates with Workflow

    Calculating the Number of Days Between Two Dates with Workflow

  8. Save the workflow and Activate it. That’s all folks! Now whenever a user enters value in ‘Sold date’, this workflow shall run and provide the number of days between Sold Date and Created on date.

    Calculating the Number of Days Between Two Dates with Workflow

The example above used the field format as Date and Time, we can keep it simple by keeping the fields format as Date Only, as well.

Make sure to stop by our main Dynamics CRM 2015 page for even more great tips and tricks!

Happy CRM’ing!

 

Avatar for JoeCRM

JoeCRM

Joe CRM is a CRM superhero who runs on pure Microsoft Dynamics CRM adrenaline. As the face of PowerObjects, Joe CRM’s mission is to reveal innovative ways to use Dynamics CRM and bring the application to more businesses and organizations around the world.