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
Swamy PSwamy P 

How to know whether current date is in last 10 business working days of an Quarter or not

Hello Everyone,

I just wanted to know whether current date is in last 10 business working days of an Quarter or not, So how can i get it? 

We have a Quarter query, with that we can fetch End Date of the Quarter. So finally how can i check whether current date is in last 10 business working days of an Quarter or not?

Your help will be really appreciated!!!
Best Answer chosen by Swamy P
Swamy PSwamy P
Finally I've created my own logic to check the condition. Below code is for our reference:

 Period PFQ = [Select StartDate, EndDate From Period Where type = 'Quarter' and StartDate = THIS_FISCAL_QUARTER];
          if(PFQ!=null){
              Date endDate = PFQ.EndDate; Date strtDate=PFQ.EndDate-14; Date tdy=Date.Today();
              Integer numberOfDays = Date.daysInMonth(tdy.year(), tdy.month());
              Date lastDateOfMonth = Date.newInstance(tdy.year(), tdy.month(), numberOfDays);
              Date startDateOfReconcile = lastDateOfMonth-14;
if((tdy>=strtDate && tdy<=endDate) || (tdy.month()==8 && tdy.year()==2016 && tdy>=startDateOfReconcile && tdy<=lastDateOfMonth)){
      LOGIC 
}