Highlighted
Micro Focus Expert
Micro Focus Expert
92 views

SM TIP: Calculate the duration between two dates fields using a ruleset PD.

Hi,

 

  • Load the unl attached which contains the JavaScript code (name: DateDifference / function: calculateDifference ) in charge of receiving 2 dates as parameters and return the difference in time between them
  • Go to Process Designer and create a new ruleset (as example I used planned.start and planned.end fileds from the cm3r table and I saved the calculation into datedifference2 field (datetime type)):
    1. Type: Run Javascript
    2. Condition: ( planned.end in CurrentRecord != 'NULL')
    3. Code: record.datedifference2=DateDifference.calculateDifference(record.planned_start,record.planned_end)
  • Add the ruleset created to the workflow(s) you want. In this example I added to the workflow properties instead of a specific phase but it’s all up to you.
  • You’ll get something like this as a result:

 

 

 

Regards,

 

 

If you feel this was helpful please click the KUDOS! thumb below!
Labels (1)
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.