You need to sign in to do that
Don't have an account?

replacing last_month
I have some code that depends on LAST_MONTH. Something like:
select .... date__c .. FROM myTable__c where date__c = LAST_MONTH
This code, as I understand, returns a result set constrained to
firstOfPastMonth <= date__c <= LastOfPastMonth
In order to make this query ready to run for any other month and not only for the last one, I tried to eliminate the use of LAST_MONTH by using variables like:
iniMonth = myToday.addMonths(-1).toStartOfMonth(); endMonth = iniMonth.addDays(date.daysInMonth((integer) iniMonth.year(), (integer) iniMonth.month()));
where myToday represents a call to a date that belongs to the month just after the needed month. So I got:
select .... date__c ... FROM myTable__c where date__c >= iniMonth AND date__c < endMonth
Am I missing something? Please, let me know Thanks
May I suggest you please check with similar post on stack exchange community with similar issue and suggested workaround.
http://salesforce.stackexchange.com/questions/160163/replacing-last-month
Please mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Best Regards,
Nagendra.
All Answers
May I suggest you please check with similar post on stack exchange community with similar issue and suggested workaround.
http://salesforce.stackexchange.com/questions/160163/replacing-last-month
Please mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Best Regards,
Nagendra.