-1

I working to calculate the business hours from the Business day:

List<BusinessHours> bhList = [SELECT FridayEndTime,FridayStartTime,Id,IsActive,IsDefault,LastModifiedById,
                              LastModifiedDate,MondayEndTime,MondayStartTime,Name,SaturdayEndTime,
                              SaturdayStartTime,SundayEndTime,SundayStartTime,SystemModstamp,ThursdayEndTime,
                              ThursdayStartTime,TimeZoneSidKey,TuesdayEndTime,TuesdayStartTime,
                              WednesdayEndTime,WednesdayStartTime FROM BusinessHours where Name='XXXX Hours'];
        System.debug('SIZE :: '+bhList.size());
        Integer businessHr = 0;
        List<Datetime> brStartTime = new List<Datetime>();
        List<Date> brEndTime = new List<Date>();
        for(BusinessHours br : bhList){
            brStartTime.add(br.MondayStartTime);
            brEndTime.add(br.MondayEndTime);
        }

        Integer diff = brEndTime.[0] - brStartTime.[0];
        System.debug('diff :: '+diff);

I am getting the below error:

Incompatible element type Time for collection of Datetime
1
  • are you still looking for answers? – Santanu Boral Aug 19 '17 at 15:10
0

MondayStartTime is type of Time where you are storing them in DateTime List. You need to change your list type to time.

List<time> brStartTime = new List<time>();
List<time> brEndTime = new List<time>();

BusinessHours

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.