Employee Year Calculation
-
Hi, I have employees table with date_of_join field and I have employee_leaves table with the following fields: employee_id leave_from leave_to total_days the employee joined on 15 Feb 2011 I want to have a query showing the cound of leaves for every employee years based on his date_of_join for example, if the employee joined on 15 Feb 2011 then the result will be like this: Feb 2011 to feb 2012 ---- totals days: 21 Feb 2012 to feb 2013 ---- totals days: 26 Feb 2013 to feb 2014 ---- totals days: 8 where Feb to feb is the employee year so it's from 15 Feb to 14 Feb every year can anyone help please?
Technology News @ www.JassimRahma.com
-
Hi, I have employees table with date_of_join field and I have employee_leaves table with the following fields: employee_id leave_from leave_to total_days the employee joined on 15 Feb 2011 I want to have a query showing the cound of leaves for every employee years based on his date_of_join for example, if the employee joined on 15 Feb 2011 then the result will be like this: Feb 2011 to feb 2012 ---- totals days: 21 Feb 2012 to feb 2013 ---- totals days: 26 Feb 2013 to feb 2014 ---- totals days: 8 where Feb to feb is the employee year so it's from 15 Feb to 14 Feb every year can anyone help please?
Technology News @ www.JassimRahma.com
-
I am not able to get it... I tried:
SELECT employee_leaves.leave_from, employee_leaves.leave_to FROM employee_leaves
JOIN leave_category ON leave_category.leave_category_id = employee_leaves.leave_category
GROUP BY YEAR(employee_leaves.leave_from);but this will just group by cal;ander year not employee year
Technology News @ www.JassimRahma.com
-
I am not able to get it... I tried:
SELECT employee_leaves.leave_from, employee_leaves.leave_to FROM employee_leaves
JOIN leave_category ON leave_category.leave_category_id = employee_leaves.leave_category
GROUP BY YEAR(employee_leaves.leave_from);but this will just group by cal;ander year not employee year
Technology News @ www.JassimRahma.com
You can only group on fields that are present within the query (or calculations based on one of those fields). You can get get the start of the contract by looking for a MIN-entry. Add 365 days to that fact, that's your range. That does not account for leap-years of course.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
You can only group on fields that are present within the query (or calculations based on one of those fields). You can get get the start of the contract by looking for a MIN-entry. Add 365 days to that fact, that's your range. That does not account for leap-years of course.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
Better add 1 year and not 365 day...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
-
Better add 1 year and not 365 day...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
-
That does not matter to SQL - it has the requested knowledge to handle the 29th of February... In fact if you are working with 365 days you have to know when to add 365 or 366 to land on the right date - otherwise you will always get 28 of February. If you work with year you will move between 28 and 29 as it proper to the year...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)