Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Is there a way to find the difference between two dates using workflows in MS CRM 4.0?

Posted on 2009-05-15
4
1,832 Views
Last Modified: 2012-05-07
I need to find out the difference between to dates and post that info to a new field.

Example:  I create a case and the creation date and time is stamped.  The modified date and time is updated whenever the case is edited.  I would like to calculate the time difference between the creation and modified in days, hours, minutes.

I would ideally like to use this is a workflow, but if it can be done with a java scripts in the onchange event that is doable as well.
0
Comment
Question by:mcrman
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:rakeshAgarwal
ID: 24421919
Hi

 You have to write  custom assembly for this.  if you want to do it in work flow. My recomendation  you should do this  by javascript . on save event

You have to get this both the field on the form in crm

 I have not tested this javascript
var createdTime = crmForm.createdon.DataValue
var modifiedTime = crmForm.modifiedon.DataValue

crmForm.<<newfield>>.DataValue = modifiedTime -createdTime

Just try above code hope that helps
reakesh
0
 
LVL 1

Author Comment

by:mcrman
ID: 24422156
If the new Field is a DATE field, and I belive it would be then this would result in the time since 01/01/1900

For example Created on is 05/10/2009 11:00am and the modifed on is 05/15/2009 12:00pm Using you formula above would result in a date time of 01/06/1900 1:00am

What i really want is 5 Days, 1 Hour.

I think I may be able to do this better in an SQL script that runs nightly.  I could perfomr all the calculation needed to get this data.

Ill post what I find and if you have any other ideas let me know.
0
 
LVL 11

Assisted Solution

by:rakeshAgarwal
rakeshAgarwal earned 250 total points
ID: 24440628
0
 
LVL 1

Accepted Solution

by:
mcrman earned 0 total points
ID: 26080791
Instead of directly executing a script against the SQL database I had a custom plugin created to calculate the day, hour, min difference between to date variables.

This way I can use workflows to perform and store these calculations
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part I
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question