You need to sign in to do that
Don't have an account?
Rohit Paul
Date Validation for 2 Months window
Hi,
I need to place a validation on one of my date fields in a Customs Object.
The following validation is required:
Lets say, the date today is 4-June-2012.
I need to place a validation where if the user selects any date lesser than 1-May-2012 the system should prompt a message on the field stating that the "Update can be done for current and previous month only".
Which means that to create a record the date selection has to be within the current month and the previous month.
Kindly suggest.
Thanks
Hi ,
Try the below Validation rule for reference(CustomDate is date type field):
if( DATE(year( CustomDate__c ),month(CustomDate__c )-2,day(CustomDate__c )) > PRIORVALUE(CustomDate__c ),true,false )
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi,
This validation is okay if the transaction is withing the year.
There is an issue when the Month entry is in January.
Eg.
Lets say the current date is 12-Jan-2012.
A new record needs to be updated.
In this case, the validation should allow the user to select any date starting from 1-Dec-2011 till 12-Jan-2012. (2 months window)
Any day before 1st Dec 2011, the system should not allow.
Can you suggest a validation for such case?
Hi,
Try the below Validation rule:
IF( OR(MONTH( newpakge__SLAExpirationDate__c ) = MONTH(TODAY() ), AND(MONTH( newpakge__SLAExpirationDate__c ) <= MONTH(TODAY() ),MONTH( newpakge__SLAExpirationDate__c ) >= MONTH(TODAY() )-1) ) , false, true)
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
IF(
OR(
NOT(MONTH(SLA_ExpirationDate__c) = MONTH(PRIORVALUE(SLA_ExpirationDate__c))),
NOT(MONTH(SLA_ExpirationDate__c) = MONTH(PRIORVALUE(SLA_ExpirationDate__c)) - 1)
), true
IF(
AND(
MONTH(PRIORVALUE(SLA_ExpirationDate__c)) = 1,
OR(
AND(
NOT(MONTH(SLA_ExpirationDate__c) = 1)
NOT(YEAR(SLA_ExpirationDate__c)) YEAR(PRIORVALUE(SLA_ExpirationDate__c))
),
AND(
NOT(MONTH(SLA_ExpirationDate__c) = 12)
NOT(YEAR(SLA_ExpirationDate__c)) = YEAR(PRIORVALUE(SLA_ExpirationDate__c)),
)
)),
true,
false
))
Hi,
I tried to prepare the validation and the following code worked:
Please check if this is okay.
Thanks