ramiwahdan Posted April 1, 2020 Share Posted April 1, 2020 (edited) Hi, I need to calculate absent percentage but not sure how. working days from Sunday to Thursday every week so 5 working days a week. i will calculate the absent days from joining date until current date. Example if joining date is 24-3-2020 and today's date is 7-4-2020 i should get the number of absent days to 11 days since both Friday and Saturday are excluded. How to do that? here is what I have: $workingdays = $curdate - $joindate; $workingdays = $workingdays - $absent = ($counter / $workingdays) * 100; the second line i missing the number of days for (Fridays and Saturdays) that should be excluded from calculations. The third line i did calculate the actual working days ($counter) for the employee so then i can get percentage of absent days. How to exclude the weekend days from calculations? Edited April 1, 2020 by ramiwahdan mistake in dates Quote Link to comment Share on other sites More sharing options...
Barand Posted April 1, 2020 Share Posted April 1, 2020 How accurate do you need to be? Over a period of time, working days = total days * 5 / 7. If you need absolute accuracy then you need the data on when they attended (or were absent) for every occurrence since they joined. Do you have that data? If you do have the data, then this is essentially the same problem as your other post about absent days. Quote Link to comment Share on other sites More sharing options...
ramiwahdan Posted April 1, 2020 Author Share Posted April 1, 2020 8 hours ago, Barand said: How accurate do you need to be? Over a period of time, working days = total days * 5 / 7. If you need absolute accuracy then you need the data on when they attended (or were absent) for every occurrence since they joined. Do you have that data? If you do have the data, then this is essentially the same problem as your other post about absent days. yes it is for the same db of absent days, so i build on the fpdf file that generates the absent days. Quote Link to comment Share on other sites More sharing options...
Barand Posted April 1, 2020 Share Posted April 1, 2020 Find the earliest join date and create a date table from then until some future date. You could make a permanent table so you always have working dates to hand and use it for all. You would then have to specify ... WHERE date BETWEEN X AND Y Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.