Business Hour Setup IMGI'm trying to calculate business hours between two days. However for some reason random days are showing up with less than 24 hours or less than 86400000 seconds in between on full day.
DateTime startDate = 2023-03-20 00:00:00; DateTime endDate = 2023-03-21 00:00:00;
BusinessHours defaultBH = [SELECT Id From BusinessHours WHERE IsDefault = true limit 1];
Long inputMillisecs = BusinessHours.diff(defaultBH.Id, startDate, endDate);
For example the results between 2023-03-20 and 2023-03-21 is 61200000 milliseconds which is 17 hours. I have no holidays setup and business hours are Mon-Fri and 24 hours a day. I'm also seeing New Years Day and some other potential US National Holidays come up with less than 24 hours such as May 29th.
Not sure why this is happening. Anywhere else could SFDC pull hours in a day?
I expect that if I have no holidays setup and default business hours set to 24 hours Mon-Fri then every weekday should return 86400000 milliseconds. This way I can rely on the number of business hours between two days. With the following:
BusinessHours defaultBH = [SELECT Id From BusinessHours WHERE IsDefault = true limit 1];
Long inputMillisecs = BusinessHours.diff(defaultBH.Id, startDate, endDate);