if(op.Country__c=='India'){
if((op.createddate > 01/01/2015)||(op.createddate < 31/03/2015))
InProjectedQ1Count = InProjectedQ1Count + 1;
if((op.createddate > 01/04/2015)||(op.createddate < 30/06/2015))
InProjectedQ2Count = InProjectedQ2Count + 1;
if((op.createddate > 01/07/2015)||(op.createddate < 30/09/2015))
InProjectedQ3Count = InProjectedQ3Count + 1;
if((op.createddate > 01/10/2015)||(op.createddate < 31/12/2015))
InProjectedQ4Count = InProjectedQ4Count + 1;
-
You could alternatively just get the month– GirbotCommented Jun 1, 2015 at 6:16
Add a comment
|
2 Answers
You can do other way round using just month & not the specific dates,
Set<Integer> Q1 = new Set<Integer>{1,2,3};
Set<Integer> Q2 = new Set<Integer>{4,5,6};
Set<Integer> Q3 = new Set<Integer>{7,8,9};
Set<Integer> Q4 = new Set<Integer>{10,11,12};
if(op.Country__c=='India'){
Integer cMonth = op.createddate.month();
if(Q1.contains(cMonth)){
InProjectedQ1Count = InProjectedQ1Count + 1;}
if(Q2.contains(cMonth)){
InProjectedQ2Count = InProjectedQ2Count + 1;}
if(Q3.contains(cMonth)){
InProjectedQ3Count = InProjectedQ3Count + 1;}
if(Q4.contains(cMonth)){
InProjectedQ4Count = InProjectedQ4Count + 1;}
}
You are probably looking for the Period object. Please have a look at the following post, I think it might help you : duplicate post
Select p.Type, p.SystemModstamp, p.StartDate, p.QuarterLabel, p.PeriodLabel, p.Number, p.IsForecastPeriod, p.Id, p.FiscalYearSettingsId, p.EndDate From Period p where p.Type = 'Quarter'