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

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

|improve this answer|||||
  • 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 Aug 12 '14 at 20:58
  • I dont understand. NOW() is the current time, current date. – Chris Duncombe Aug 12 '14 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 Aug 12 '14 at 21:34
  • What time Zone are you in? Formulas will use GMT time so this could be the issue. – Chris Duncombe Aug 12 '14 at 21:56
  • 1
    Add 1 to the result of the formula? IF( ISPICKVAL(Status__c, 'Draft'), (NOW() - LastModifiedDate)+1, CreatedDate - LastModifiedDate ) – HomerJ Dec 26 '14 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.