1

I would like to write a formula to count the number of days based on the conditions mentioned below..

If the Status__c (Picklist field) = Draft, calculate based on Now() - Last modifed date.

If the Satus__c is another pick-list value other than draft, calculate based on Created date - Lastmodified date

1 Answer 1

2

Something like this will work

IF(
     ISPICKVAL(Status__c, 'Draft'),
     NOW() - LastModifiedDate,
     CreatedDate - LastModifiedDate
)

For more info on Formulas and Operators check some of these out

https://help.salesforce.com/HTViewHelpDoc?id=customize_functions.htm&language=en_US

https://developer.salesforce.com/page/An_Introduction_to_Formulas

http://www.salesforce.com/us/developer/docs/usefulFormulaFields/

https://help.salesforce.com/HTViewHelpDoc?id=tips_on_building_formulas.htm&language=en_US

6
  • HI Ninja,Thanks for your answer it works..One more question the number of days difference wasn't included with todays date. How do we manipulate this formula to include todays date in that calculation
    – Rock
    Commented Aug 12, 2014 at 20:58
  • I dont understand. NOW() is the current time, current date. Commented Aug 12, 2014 at 21:27
  • With this formula, it was calculating in this way..Ex: Now (08/12) - Created date (08/08) = 4. But, I want to include the today's date so that it will give 5 days instead of 4.Let me know how to achieve it
    – Rock
    Commented Aug 12, 2014 at 21:34
  • What time Zone are you in? Formulas will use GMT time so this could be the issue. Commented Aug 12, 2014 at 21:56
  • 1
    Add 1 to the result of the formula? IF( ISPICKVAL(Status__c, 'Draft'), (NOW() - LastModifiedDate)+1, CreatedDate - LastModifiedDate )
    – HomerJ
    Commented Dec 26, 2014 at 19:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .