You need to sign in to do that
Don't have an account?
saulosb
BusinessHours.diff
Hi
I am as a problem to know the difference between two dates.
datainicial: 2016-09-19 00:00:00
datafim:2016-09-20 00:00:00
Anyone know how to solve?
I am as a problem to know the difference between two dates.
datainicial: 2016-09-19 00:00:00
datafim:2016-09-20 00:00:00
public static integer calcula(String id,DateTime datainicial,DateTime datafim){ BusinessHours bh = [SELECT id From BusinessHours Where id=:id]; Long businessDiff = BusinessHours.diff(bh.Id, datainicial, datafim); System.debug('businessDiff:'+businessDiff); String strDataInicial = datainicial.format('EEE'); String strDataFim = datafim.format('EEE'); System.debug('strDataInicial:'+strDataInicial); System.debug('strDataFim:'+strDataFim); Long seconds = businessDiff / 1000; Long minutes = seconds / 60; Long hours = minutes / 60; Long dia = hours / 24; System.debug('diaCalculado'+dia); return dia.intValue(); }The code is putting the start date to Sunday and it is a Monday, so I'm always with return 0.
Anyone know how to solve?
saulosb
User locale = pt-br.