There is no way to achieve you goal as 25 is not between 5 and 25.
Or you could simply do this which would be best if the period changes for each records:
for(sObject rec : YOURRECORDS){
if(Period1.LowerDate__c <= rec.TRIG_DATE__c && Period1.UpperDate__c >= rec.TRIG_DATE__c){
//is period 1
}else if(Period2.LowerDate__c <= rec.TRIG_DATE__c && Period2.UpperDate__c >= rec.TRIG_DATE__c){
//is period 2
}
}
Or if the Period1 and 2 are static for all records (depending on profiling)
Set<Integer> period1 = New Set<Integer>();
Set<Integer> period2 = New Set<Integer>();
//You will need to add obligatory error checking for null fields, etc
for(Integer x=Period1__c.LowerDate__c;x<=Period1__c.UpperDate__c;x++)
Period1.add(x);
for(Integer x=Period2__c.LowerDate__c;x<=Period2__c.UpperDate__c;x++)
Period2.add(x);
for(sObject rec : YOURRECORDS){
if(Period1.contains(rec.TRIG_DATE__c){
//is period 1
}else if(Period2.contains(rec.TRIG_DATE)){
//is period 2
}
}
Profiling both with bulk data may be in order as I do not recall if contains
is more or less costly than getting a two fields and comparing them each time. Even so it may be negligible so this would be the way to go me thinks
Depending on your data model this could be modified based on your needs. I am sure there are better ways but it is late...How you design your data model will determine how well this can scale. You would not want say 20 different periods to be done this way. If that was the case I would look into using custom settings/metadata to define periods. If the periods are different for each record that is another story.
but your question is vague so this answer may not cover your use case