Skip to main content

Need help in Date Validation Rule and formula

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

Default Value for Above Date Field with formula

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. My first question Is this formula is correct for making ahead of 6months from today's date? Will it consider Months having 30 and 31st automatically?

I have one more doubt I have one validation rule if we keep less than 6 months date (Last_Order_Date__c )then I am 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 this date also.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.