function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
indyindy 

Business Hours calculation is incorrect/ not consistent for certain dates

My use case is to calculate the deadline to respond on the Case. Rule is to add 10 business days from the complaint received date.
1.    Defined the business hours:
 User-added image2. Logic 1
 
Date initialDate = Complaint_Receive__c;
	Datetime datetime = datetime.newInstance(initialDate.year(), initialDate.month(),initialDate.day());
	Datetime deadline = BusinessHours.addGmt (stdBusinessHours.id, datetime, 10 * 24 * 60 * 60 * 1000L);
	Datetime casedeadline = date.newinstance(deadline.year(), deadline.month(), deadline.day());

If the Complaint Received date is 04/01 then the deadline should be 04/15. But the above logic is returning 04/13 which is Saturday.
But if I change the logic to the below it is returning the deadline as 04/15 which is accurate.

Logic 2
 
Date initialDate = Complaint_Receive__c;
	Date initialDatePlus = Complaint_Receive__c.addDays(1);
	Datetime datetime = datetime.newInstance(initialDate.year(), initialDate.month(),initialDate.day());
	Datetime deadline = BusinessHours.addGmt (stdBusinessHours.id, datetime, 10 * 23 * 60 * 60 * 1000L);

The only difference is adding one day to the complaint received date and used 23 hours in addGmt method instead of 24.

​​​​​​​To me Salesforce should return the deadline as 04/15 for Logic 1 itself. Please explain what I am missing here.

Note - Interestingly the Logic 1 is working  for some of the date but not all.