You need to sign in to do that
Don't have an account?
EmilyCobb
Date range comparison without a year
I have a table of date ranges split out by day and month, and I need to determine if a user provided date falls within the range.
I have no years in the table. I was using this logic:
Thanks
I have no years in the table. I was using this logic:
if(qRec.Expected_Start_Date__c >= Date.newInstance(qRec.Expected_Start_Date__c.year(), Integer.valueOf(soqlResults.Start_Month__c), Integer.valueOf(soqlResults.Start_Day__c)) && qRec.Expected_Start_Date__c <= Date.newInstance(qRec.Expected_Start_Date__c.year(), Integer.valueOf(soqlResults.End_Month__c), Integer.valueOf(solqResults.End_Day__c))){Which works for the majority of the use cases, until it crosses a year and needs to fall into the 12/25 - 1/24 range. I'd prefer to take year out of the comparison all together, as it is not relevant. Any suggestions appreciated.
Thanks
I probably would create a static method in a Service class a little bit like the following: Can be simplified a little... I have not tested the code, and is full of comments, but it is just to give an Idea...
Good Luck :)