I'm using BusinessHours class and the add method. I need to set a date field to a specific hour the following day. Here is my pseudo code:

Datetime targetDate = system.now();
if(condition is met) {
MyDateField__c = BusinessHours.add(bh.Id, targetDate, ???); // need to set to 7pm the next day in EST timezone

How can I calculate to a specific hour the next day from the target date?


Don't use BusinessHours if you are trying to set a specific time. I recommend you use Datetime.newInstance(Date, Time):

Datetime target = Datetime.newInstance(
    Time.newInstance(19, 0, 0, 0)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.