0
IF( 
OR(  
Date__c  < (TODAY() - MOD(TODAY()- DATE(1900,1,8),7)), 
Date__c  > (TODAY() + MOD(TODAY()- DATE(1900,1,8),7))
), 
true,
false)

The previous formula raises a syntax error.

4
  • 1
    Hi @AshishSoni, welcome to SFSE! Please take a moment to visit the help center and read How to Ask. Commented Aug 10, 2017 at 9:41
  • 1
    Which Synxtax error are you getting? I'm getting no syntax error with your code (changing the Date__c field for another Date field) Commented Aug 10, 2017 at 9:50
  • 4
    Also note that the IF is redundant here.
    – Keith C
    Commented Aug 10, 2017 at 9:52
  • 1
    Yes, you can always replace IF(condition, true, false) with simply condition.
    – Adrian Larson
    Commented Aug 10, 2017 at 10:58

1 Answer 1

1

You're missing these () brackets across your OR conditions. It's good to use those () brackets if you've multiple conditions. Refer below:

IF( 
    OR( 
        (Date__c < (TODAY() - MOD((TODAY()- DATE(1900,1,8)),7))),
        (Date__c > (TODAY() + MOD((TODAY()- DATE(1900,1,8)),7)))
    )
    ,true,false 
)

Above validation might solve your problem but it's good to use AND instead of IF. Here is example:

AND( 
    OR( 
        (Date__c < (TODAY() - MOD((TODAY()- DATE(1900,1,8)),7))),
        (Date__c > (TODAY() + MOD((TODAY()- DATE(1900,1,8)),7)))
    )
)
2
  • @AshishSoni You can accept the answer so that it could be useful for others too Commented Aug 10, 2017 at 10:07
  • 1
    The AND/IF are both unnecessary.
    – Adrian Larson
    Commented Aug 10, 2017 at 10:57

You must log in to answer this question.

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