Question : Date SQL


I need to setup a system that calculates a employees holiday allowance.

Basically an employess get 1.6 days holiday for every month they have worked for the company.  The maximum number of holidays is 20 per year so they would have to have been working for the company for a 12 months in order to get the full entitlement.

The employee details are held in a table and each record has a startdate

Can anyone suggest what way is best to sachieve this in SQL.

Thanks





Answer : Date SQL

SELECT Employee, DATEDIFF("m",StartDate,NOW())*1.6 FROM table

There's only one problem with this, though:
Someone entering on 1-Jan would have the same amount of days as someone entering on 31-Jan. DATEDIFF only checks different months without checking the days. Anyway, this is a good start, and probably another expert can improve it.
Random Solutions  
 
programming4us programming4us