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
DILEEP NALLADILEEP NALLA 

How to validate Month of an existing date field in my object

I have requirement that I need to make sure previous month record should not be entered in current month
I need to validate Previous month and current month
How to implement this code using triggers ?
Apex code required..Please help
Amit Chaudhary 8Amit Chaudhary 8
Please create validation. Please try below. I hope that will help u

Date Must Be in the Current Month
OR (
YEAR( My_Date__c ) <> YEAR ( TODAY() ),
MONTH( My_Date__c ) <> MONTH ( TODAY() )
)
Date Must Be in the Current Year
YEAR( My_Date__c ) <> YEAR ( TODAY() )
https://help.salesforce.com/HTViewHelpDoc?id=fields_useful_validation_formulas_date.htm
https://developer.salesforce.com/docs/atlas.en-us.usefulValidationRules.meta/usefulValidationRules/fields_useful_validation_formulas_date.htm

Please let us know if that will help u

Thanks
Amit Chaudhary