Create a field using Today's Current Date
search cancel

Create a field using Today's Current Date

book

Article ID: 245087

calendar_today

Updated On:

Products

Clarity PPM On Premise Clarity PPM SaaS

Issue/Introduction

I would like to create a number field on the Task Object to show how many days have elapsed from the Start Date to the Current Date. 

How do I create a field like this? 

Environment

Release: 15.8.x, 15.9.x, 16.x 

Clarity Studio 

Resolution

You can use the Now() function in a Calculated attribute that returns the result as a number. 

Follow the steps below: 

  1. Go to Classic Administration, Studio: Objects, Task Object, Attributes tab 
  2. Click 'New' button to create a new Calculated Number field
    • Attribute Name = Days Elapsed
    • Attribute Id = days_elapsed
    • Data Type = Calculated 
    • Result Data Type = Number 
    • API Attribute ID = c_daysElapsed 
  3. Click 'Save' button
  4. Click [Build Calculated Attribute] hyperlink
    • Function = DateDiff 
    • Argument 1, Attribute Name = Start (prstart) 
    • Argument 2, Sub-expression = Now() 
    • Argument 3, Constant = Day 
  5. Click 'Generate' button 
    • Expression = DateDiff(prstart,[Now()],"Day") 
    • Click 'Validate' and it is NOT Valid you will see the following error 
      • ODF-0010: Invalid expression. Check the format to make sure it is correct. 
    • The [ ] symbols need to be removed 
    • Update the expression 
    • Expression = DateDiff(prstart,Now(),"Day") 
    • Click 'Validate' and it is now valid
      • ODF-0020: The expression syntax is valid. 
  6. Click 'Save and Return' button
  7. [Optional] The Display Mappings can be configured with colors, if desired 
  8. Click 'Save and Return' button 
  9. Navigate to the Modern UX
  10. For any Investment, go to the TASKS Module 
  11. Add the 'Days Elapsed' field to the grid columns

 

 

Today is June 30, 2022:

  • A positive number displays if the Start Date is in the past 
  • A negative number displays if the Start Date is in the future 

 

Additional Information

Attachments