Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Detecting active date ranges

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-04-08 : 09:08:10
Doug writes "Hopefully you folks can shed some light on this problem I'm having. BTW, the following article seems to be closest to what I need to do:

http://www.sqlteam.com/item.asp?ItemID=12654

I need to set up an employee database in SQL Server that, among other things, tracks active date ranges for employees.

Forinstance, say the following dates apply to an employee:

5/12/01 - hired
6/10/01 - terminated
7/1/02 - hired (rehired)
8/10/03 - transfer
9/11/03 - terminated
1/1/04 - hired (rehired)

For reporting purposes, I need to be able to know that this employee should only be counted in data ranges

5/12/01 - 6/10/01 and
7/1/02 - 9/11/03 and
1/1/04 to the present

I'm having a devil of a time figuring out what the table should look like, and what the query to retrieve the data would be. Could you assist please?

The article I list above does this to a degree, but does not compensate for if the employee is still currently an employee.

Thank you!"
   

- Advertisement -