function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JJJenkinsJJJenkins 

Validation comparing now() to a set time

I'm having trouble writing a validation rule where I would compare now() to a set time.

 

What I'm trying to do is say when a custom date field is changed if the time the change is happening is after 12 noon to fire the validation.

 

Here are the different ways I've attempted this:

AND(
ISCHANGED(Date__c),
Date__c = Today()+1,
NOW()> DATETIMEVALUE(TEXT(YEAR(TODAY()))+"-" +TEXT(MONTH(TODAY()))+"-" +TEXT(DAY(TODAY()))+" "+"12"+ ":00"+":00")
)

 I've also tried:

AND(
ISCHANGED(Date__c),
Date__c = Today()+1,
NOW()> VALUE(MID(TEXT(NOW()),12,2))>12
)

 Any help would be appreciated.

 

Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
SeAlVaSeAlVa

What about

AND(
   ISCHANGED(date__c),
   date__c = TODAY()+1,
   DATEVALUE(NOW()+0.5) = date__c
)

If that works, you can even delete "date__c = TODAY()+1,"

 Regards

All Answers

SeAlVaSeAlVa

What about

AND(
   ISCHANGED(date__c),
   date__c = TODAY()+1,
   DATEVALUE(NOW()+0.5) = date__c
)

If that works, you can even delete "date__c = TODAY()+1,"

 Regards

This was selected as the best answer
JJJenkinsJJJenkins

Thank you!  I was obviously overcomplicating this - just need a fresh set of eyes sometimes.