2

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.

1
  • 2
    I think you're mixing Date and Datetime. Try using NOW instead of TODAY.
    – Adrian Larson
    Feb 29, 2016 at 21:01

1 Answer 1

5

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.

You must log in to answer this question.

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