Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a formula field as a checkbox and this is the formula: (TODAY() -  LastModifiedDate ) <= 30

I get and error stating: "Error: Incorrect parameter type for operator '-'. Expected Number, Date, received DateTime"

I want this box to check if there has been activity within the last 30 days.

share|improve this question
2  
I think you're mixing Date and Datetime. Try using NOW instead of TODAY. – Adrian Larson Feb 29 at 21:01

You can use the DATEVALUE() formula to convert a DateTime to a Date. Alternatively, you could use NOW() instead of TODAY(). It really depends on the amount of accuracy you want: using NOW() gives you to the second accuracy, while using DATEVALUE() will cause the system to calculate the number of days based on midnight-to-midnight ranges.

TODAY() - DATEVALUE(LastModifiedDate) <= 30 // Accurate to 24 hours

NOW() - LastModifiedDate <= 30 // Accurate to the nearest second

Edit: I just realized that I should mention that using TODAY/DATEVALUE will cause users in different time zones to possibly see different values, while using NOW should result in any user in any time zone seeing the same value. This has to do with the fact that TODAY() and DATEVALUE() convert times to local time zones when used, while using NOW directly will be time-zone agnostic.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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