Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help creating a history...

Status
Not open for further replies.

Shawn12

Programmer
Sep 27, 2006
50
US
Hi,

I am trying to create a historical record of Employees at our business. What I would like to do is have a query that will create a begin date and create that date for each day starting w/ like 1/1/06 and continue thru Date()-1. For example:

Jane Doe and John Doe started employment on 1/1/06. Jane Doe was employed until 1/5/06. So using their "Hire Date" I would like the query to do this..

Created Name Hire Date Termination

1/1/06 Jane Doe 1/1/06 1/5/06
1/1/06 John Doe 1/1/06
1/2/06 Jane Doe 1/1/06 1/5/06
1/2/06 John Doe 1/1/06
1/3/06 Jane Doe 1/1/06 1/5/06
1/3/06 John Doe 1/1/06
1/4/06 Jane Doe 1/1/06 1/5/06
1/4/06 John Doe 1/1/06
1/5/06 Jane Doe 1/1/06 1/5/06
1/5/06 John Doe 1/1/06
1/6/06 John Doe 1/1/06
1/7/06 John Doe 1/1/06

So in this case Jane Doe will show up every day in the "Employee List" until she was terminated. Is it possible to loop a date like this in a query or will I have to make an estranged table with a list of dates? TIA for any help.

 
Well, you can't really make a query loop, but you can run it multiple times and build up a recordset by appending each day's results. The best way that occurs to me to do this is to use a while loop to loop from your start date to Date()-1 and use a select query to pick out all the employees for whom the date you're on is between their hire and termination dates, then loop through the query results and append them to your recordset.

TMTOWDI - it's not just for Perl any more
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top