You need to sign in to do that
Don't have an account?
keithpeters
Problem with the BusinessHours.diff method... only on the 13th of March :-/
Hi,
I created a BusinessHours object that defines the business hours between 2 AM and 3 AM each day (including weekends).
So when I run the following code, it usually returns 1800000 (i.e. 30 minutes); Except when I run it for 2011-3-13.
System.debug(BusinessHours.diff( [select id from BusinessHours where Name = 'test 2 - 3 every day' limit 1].Id, Datetime.newInstance(2011, 3, 13, 2, 0, 0), Datetime.newInstance(2011, 3, 13, 2, 30, 0))); 06:46:40.037|METHOD_EXIT|[1]|BusinessHours.diff(String, Datetime, Datetime) 06:46:40.037|USER_DEBUG|[1]|DEBUG|0
Note also that I don't have any holidays attached to these business hours.
Any help would be much appreciated, thank you.
Hi,
Thanks very much for getting back so quickly however the query isn't the issue, the one in my code snippet works but for some reason, the diff method does not return the correct result for that particular day.
Can't figure out why that would be, like I said, there are no holidays attached to that BusinessHours object. Do they run with a default set?
At any rate, thanks again for the response, I'd tried your change but it didn't make any difference.
How did you define your business hours?
Did you include Satuday and Sunday into the business hours?
Yes, I have times for every day. Running the following:
Produces: