You need to sign in to do that
Don't have an account?
D harish
how to calculate difference between working hours of a day in apex
Hi,
I am using Business hours object to calculate the difference between two days using apex.Here i am facing a problem to calculate the difference between start time and end time of a business day(Ex.difference between Mondayendtime and Mondaystarttime)
is there method to calculate the difference?
can someone post the syntax how to calculate the difference between start time and end time of a business day?
Hi,
as I understand your question you want to calculate the difference between 2 dateTime variables.
Here is an example:
Long diff = DateTime.now().addMinutes(5).getTime() - DateTime.now().getTime();
// diff is in this case 300000 mili sec = 300 sec = 5 mins
//In your case
DateTime Mondayendtime = DateTime.now().addHours(-8);
DateTime Mondaystarttime = DateTime.now();
Long diff2 = MondayendtimegetTime() - Mondaystarttime.getTime();
diff2 = diff2/1000/60/60;
System.debug('diff in hours' + diff2);
Christian
Hey harish you can try this
this difference is in hours
currentStartOfWeek, finalStartOfWeek .........these are date fields.
//calculating final value
ageDifferece = ((finalStartOfWeek.getTime())/1000/60/60) - ((currentStartOfWeek.getTime())/1000/60/60);
Thanks
Abhi