Date and Duration Calculation

Primavera Cloud Expression Language provides several methods for date calculations. Use date and duration methods when specifying fields or measures that modify data from date fields such as Project Planned Start or Project Planned Finish. For example, you may want to define a configured field for the Project object that returns the date six months after the current project's Planned Start Date. To do so, use the plusMonths date method as shown in the following example:

return plusMonths(object.Project_planStartDate, 6);

You can also use Primavera Cloud Expression Language date methods to perform calculations and set field values based on the contents of multiple date fields. Complete the following task to practice using Primavera Cloud Expression Language date methods.

To define a configured field that returns a message based on a project's Planned End Date and Percent Complete:

  1. In the object selector, select a workspace.
  2. In the sidebar, select Summary & Settings.
  3. On the Summary & Settings menu, select Defaults & Options, and then select Project.
  4. On the Projects page, select the Configured Fields tab.
  5. In the table, select Add:
    1. In the Column Label column, enter Anticipated Delays.
    2. In the View Column Name column, enter AD.
    3. In the Data Type column, select Text.
    4. In the Type column, select Formula.
  6. In the Formula detail window, in the Formula Editor, enter the following:

    def currentDate = new Date();
    def weekFromFinish = minusDays(object.Project_planEndDate, 7);
    if(object.Project_percentComplete < 95 && currentDate >= weekFromFinish){
    return "Project delay likely";
    } else {
    return "No delays anticipated.";
    }

  7. In the Formula detail window, select Validate Formula.
  8. In the Formula Validation dialog box, select OK.
  9. Select Save.

To learn more about Primavera Cloud Expression Language date and duration methods, see Date Methods and Duration Methods.



Last Published Tuesday, May 21, 2024