Hi all
I have a table let's call it "Emp". In that table I have Seq as primery key, IdEmp, StartDate as Date, EndDate as Date.
The same Employe can have many records in that table. "Employe1" can starts work in 18/1/2000 and quit work in 25/5/2001, then restart work in 3/3/2005 and still working till now, So not having an EndDate for the second record. Clear?
Table should looks like the following:
Seq--IdEmp--StartDate--EndDate
1------1---------18/1/2000--25/5/2001
2------1----------3/3/2005-- Null
My Q is:
How can I count months that Employe1 had realy worked?
Note that I want to count the complete months, If any start date is not from the biginnig of the month, that month is not counted. The same as for the end date, any end date not reaching the end of the month, that month is not counted.
The result for peivious exemple:
from 1/2/2000 to 30/4/2001 : 15
from 1/4/2005 to 30/4/2007 : 25
15+25=40 months
I have a table let's call it "Emp". In that table I have Seq as primery key, IdEmp, StartDate as Date, EndDate as Date.
The same Employe can have many records in that table. "Employe1" can starts work in 18/1/2000 and quit work in 25/5/2001, then restart work in 3/3/2005 and still working till now, So not having an EndDate for the second record. Clear?
Table should looks like the following:
Seq--IdEmp--StartDate--EndDate
1------1---------18/1/2000--25/5/2001
2------1----------3/3/2005-- Null
My Q is:
How can I count months that Employe1 had realy worked?
Note that I want to count the complete months, If any start date is not from the biginnig of the month, that month is not counted. The same as for the end date, any end date not reaching the end of the month, that month is not counted.
The result for peivious exemple:
from 1/2/2000 to 30/4/2001 : 15
from 1/4/2005 to 30/4/2007 : 25
15+25=40 months
Comment