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.
ShowAll Questionssorted byDate Posted andyaldis1.3969086903835708E12

# Check if an Activity Date is in the current quarter

Hello,

I have to write a if statement that will check if the ActivityDate on a task is in the current quarter.  Does anyone have a quick trick on how I can do that?  I figure it has to be a pretty common formula. Best Answer chosen by andyaldis1.3969086903835708E12 TJ D
If you are looking for non-apex based solution then follow below article-
https://help.salesforce.com/articleView?id=000004173&type=1

If you need this in apex; you can try using period object. Below query gives you a start date and end date-
```Date startDate = [Select startdate From Period Where type = 'Quarter' and StartDate = THIS_FISCAL_QUARTER].startdate;
Date endDate = [Select enddate From Period Where type = 'Quarter' and StartDate = THIS_FISCAL_QUARTER].enddate;```
then use if statement to check-
```if(ActivityDate > startDate && ActivityDate < endDate){
}```

Let me know if it works. TJ D
If you are looking for non-apex based solution then follow below article-
https://help.salesforce.com/articleView?id=000004173&type=1

If you need this in apex; you can try using period object. Below query gives you a start date and end date-
```Date startDate = [Select startdate From Period Where type = 'Quarter' and StartDate = THIS_FISCAL_QUARTER].startdate;
Date endDate = [Select enddate From Period Where type = 'Quarter' and StartDate = THIS_FISCAL_QUARTER].enddate;```
then use if statement to check-
```if(ActivityDate > startDate && ActivityDate < endDate){ TJ D