using datediffhours function I am getting 24 hours if i select the date for one day( from 1/17/2015 to 1/18/2015) want to change to 8 hours per day instead of 24 hours.
Solved! Go to Solution.
Hi Muffaddal,
Apologies if I haven't understood you correctly but I understand you want to calculate the number of hours difference between two dates but you're treating each day as a "working day" e.g. 8 hours per day instead of 24. In that case, do you need to cater for weekends and public holidays too?
It seems the easiest solution is to continue to use dateDiffHours but divide the result by 3 to get an answer in multiples of 8 but if you have to cater for weekends etc then you'll need even more logic.
Hope that helps.
Cheers,
Chris
Depending on your needs it can be as simple as using Datediff in days, then multiply by 8.
This would mean however that only whole days will be calculated.
If you need to subtract weekends I suggest looking at Vadim's post to learn how to extract the date values and handle them in Javascript.
Nintex Forms - Date Calculations with Javascript - Vadim Tabakman
Then use something like
http://partialclass.blogspot.nl/2011/07/calculating-working-days-between-two.html
to handle those dates returning the working days only.