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
Érick BSÉrick BS 

Validation Rule function MONTH()

Hi! I am facing a small problem, but so far I was not able to solve this issue.
Is anyone can help me to solve this?

The function MONTH(TODAY())-3 should return 11, but I think that is return -1 and of course does not exist the month -1 :)
Redlining__Effec_Date__c <
DATE(YEAR(TODAY()),MONTH(TODAY())-3,DAY(TODAY()))

 
Dano BlevinsDano Blevins

Have you tried running a CASE function first where you get the current month, and return 3 months before, then use that as the MONTH? 

 

Redlining_Effec_Date__c(
DATE(YEAR(TODAY()),
MONTH(CASE(MONTH(TODAY()),
1,10,
2,11,
3,12,
4,1,
5,2,
6,3,
7,4,
8,5,
9,6,
10,7,
11,8,
9),
DAY(TODAY()))
 

Using the CASE fucntion will give you a set result depending on what went in, just remember it has to end with an ELSE line so I included DECEMBER wich would give a 9 as simply the 9.
 

Érick BSÉrick BS
Hi Buddy!

First, thank you very much for helping.
I've been working as a Salesforce developer for a small-time...

I tried your suggestion but is not working... Now is showing the message "Error: Incorrect parameter type for function 'MONTH()'. Expected Date, received Number".

I tried to use convert data like DATEVALUE, but still does not work.
Could you help again? Pls
 
Redlining_Effec_Date__c <
DATE(YEAR(TODAY()),MONTH(CASE(MONTH(TODAY()),
1,10,
2,11,
3,12,
4,1,
5,2,
6,3,
7,4,
8,5,
9,6,
10,7,
11,8,
9)),DAY(TODAY()))


 
Érick BSÉrick BS
It is almost done!! But something wrong for lead year :(
For the months 2, 3, 4 and 5 I can’t solve it... 
 
OR(
Redlining__Effec_Date__c < 
IF  (
    (MOD(YEAR(APXT_Redlining__Effective_Date__c),4) == 0 && (MOD(YEAR(APXT_Redlining__Effective_Date__c),100) != 0 || MOD(YEAR(APXT_Redlining__Effective_Date__c),400) == 0)),
    IF (
        MONTH(APXT_Redlining__Effective_Date__c) <> 2 ||
        MONTH(APXT_Redlining__Effective_Date__c) <> 3 ||
        MONTH(APXT_Redlining__Effective_Date__c) <> 4 ||
        MONTH(APXT_Redlining__Effective_Date__c) <> 5,
        DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY()))-91.25,
        DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY()))-91.375            
        ),
    DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY()))-91.25           
    )
)

 
Dano BlevinsDano Blevins
Have you tried != in place of <>