This might be a very easy question but I just wanted to make myself clear on it.

This is to be done in a validation rule formula. Say the date time field is Test__c

1) I need to compare a date time field value if it is greater than Yesterday.

2) Compare a date time field value if greater than a specific date.

3) greater than LAST_N_DAYS: 2 (What this actually mean? Day before yesterday or a day even before that?)

2 Answers 2


You can just check

Test__c = Now() - 2


Test__c = Now() - 3

The number has to be subtracted from Now() function. Validation rule will fire when it will return TRUE.

  • For point 1 which answer would be correct? Jun 1, 2017 at 9:19
  • 2
    Datevalue(Test__c) > Today() - 1 Jun 1, 2017 at 9:24

you can use the DATEVALUE(datetime field) function to extract the date part from the date/time field and then compare it with values like TODAY() - 1 or any specific date value ... you can use DATE(year, month, day) function to build a static date to compare..

refer this salesforce help for sample date & datetime formulas

You must log in to answer this question.

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