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
Akarsh SharmaAkarsh Sharma 

Validates that a custom date field contains a date within the current month and year.through if conition

Best Answer chosen by Akarsh Sharma
AnkaiahAnkaiah (Salesforce Developers) 
Hi Akarsh,

try with below code.
date currentdate = system.today();
If (Acc.Custondate__C.Month()== currentdate.Month() && acc.Custondate__C.Year()==currentdate.year()){

}

If this helps, Please mark it as best answer.

Thanks!!

All Answers

AnkaiahAnkaiah (Salesforce Developers) 
Hi Akarsh,

try with below code.
date currentdate = system.today();
If (Acc.Custondate__C.Month()== currentdate.Month() && acc.Custondate__C.Year()==currentdate.year()){

}

If this helps, Please mark it as best answer.

Thanks!!
This was selected as the best answer
Akarsh SharmaAkarsh Sharma
thanks , Ankaiah