Skip to main content
1 of 8

Need help in Date Validation Rule

I have a date field (Last_Order_Date__c)in which I am defaulting the value of date to 6 months ahead from today's date.

DATE( 
YEAR(TODAY()) + IF(MONTH(TODAY()) > 6, 1, 0), 
MOD(MONTH(TODAY()) + 6, 12), 
DAY(TODAY()) 
)

Right now it is defaulting the value correctly. Suppose today is 10/29/2016 .It is defaultly setting to this value 4/29/2017. Is this formula is correct ? Will it consider Month having 30 and 31st automatically?

I have written validation rule if it is less than 6 months set date then throwing an error message "Last Order Date should be greater than 6 Months from Today." Validation Rule -

IF(Last_Order_Date__c <=(DATE( 
YEAR(TODAY()) + IF(MONTH(TODAY()) > 6, 1, 0), 
MOD(MONTH(TODAY()) + 6, 12), 
DAY(TODAY()))), TRUE, FALSE)

As I am defaulting the value to 6 months ahead .The value of the date field is 4/29/2017. While Saving the record it is throwing error for 4/29/2017.I need it should not throw error if it is 4/29/2017.If it is less than then 4/29/2017 then only throw an error.