I have a table 'data' in which there are two columns i.e. Startdate and Enddate.
Startdate is the date when an employee joined working in a company and Enddate is the date when he left. I need to find the working days of employee per month.
If the Startdate is '2015-06-21' and the Enddate is '2015-08-21' then the working days will be:
June 10days July 31days August 21days
I have the query for the total days for the work:
Select datediff(dd,startdate,enddate) from tablename
but I need to take the days as above (per month).
I actually have three columns, 'Startdate', 'Enddate' and 'Salary'. The full query needs to divide the salary over the calendar months. If salary is 620 then for the above dates sample the result is:
June-for 10 days = 100 July = 310 August = 210