You need to sign in to do that
Don't have an account?
Developers
How to calculate due date excluding weekends in apex controller?
Hi Friends,
I have some requirement to calculate the due date excluding weekends. But, this could be calculated in apex controllers to be used in adhoc report. This calculations requires in apex controller to get no.of business days to calculate the due date value. It may be 30 days, 60 days, 90 days or 180 days due date from the source date. For Ex; Record createdDate.addDays(30), generally gives post date value after 30 days from this created date. But, I need to get Date value as 30th Business day from the createdDate value which excludes weekends.
I have gone through some urls which suggests to create a formula field on object level. But, in my case, i need to do this calculation in apex controller and need to display due date value on my custom vf page and no need to capture in any salesforce object. I also used some custom logic which is used to get no.of business days between two dates. But, that login throws me CPU time limit exceed error while doing calculation for bulk records.
Please help me how to do this calculation.
Thanks,
Phanikumar
I have some requirement to calculate the due date excluding weekends. But, this could be calculated in apex controllers to be used in adhoc report. This calculations requires in apex controller to get no.of business days to calculate the due date value. It may be 30 days, 60 days, 90 days or 180 days due date from the source date. For Ex; Record createdDate.addDays(30), generally gives post date value after 30 days from this created date. But, I need to get Date value as 30th Business day from the createdDate value which excludes weekends.
I have gone through some urls which suggests to create a formula field on object level. But, in my case, i need to do this calculation in apex controller and need to display due date value on my custom vf page and no need to capture in any salesforce object. I also used some custom logic which is used to get no.of business days between two dates. But, that login throws me CPU time limit exceed error while doing calculation for bulk records.
Please help me how to do this calculation.
Thanks,
Phanikumar
Please see salesforce link which will help you in calculating weekday's and weekend formulas.
https://help.salesforce.com/HTViewSolution?id=000004526
Thanks
Please help me.
Thanks,
Phanikumar
Please go through this blog and see if this help you.
http://sfdcbydev.blogspot.in/2016/01/working-day-calculation-apex.html
Thanks,