Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. BusinessHours bh = [SELECT FridayEndTime,FridayStartTime,Id,MondayEndTime,MondayStartTime,
  2. FROM BusinessHours where Name='Test Business Hour'
  3. LIMIT 1];
  4. Time startTime = bh.MondayStartTime;
  5. Time endTime = bh.MondayEndTime;
  6.  
  7. Date d = Date.today();
  8. Datetime monTodaystart = Datetime.newInstance(d.year(),d.month(),d.day(),startTime.hour(), startTime.minute(),startTime.second());
  9. Datetime monTodayend = Datetime.newInstance(d.year(),d.month(),d.day(),endTime.hour(), endTime.minute(),endTime.second());
  10. System.debug('monTodaystart :: '+monTodaystart);
  11. System.debug('monTodayend :: '+monTodayend);
  12.  
  13. Long diff = BusinessHours.diff(bh.Id, monTodaystart, monTodayend);
  14. System.debug('diff :: '+diff);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement