Need to create calendar table

G

Guest

I'm needing to create a calendar table in my database - fields should be
date, start time, and end time (hour blocks from 8 am to 8 pm). I want to
have it as a macro, maybe prompting the end user to enter the year and
creating the table (or appending new year's records in existing calendar
table) in the background. Weekdays only would be ideal but quickest solution
to this much appreciated.

Ex:
Date StartTime EndTime
01/01/07 8:00 am 9:00 am
01/02/07 9:00 am 10:00 am
....
12/31/07 8:00 pm 9:00 pm
 
G

Guest

Seems like a waste but here is how you can do it.

First in Excel using the autofill create a column of 365 days.
Create your table in Access. Import the 365 days.
Use a query to find weekends like this ---
WeekendDate: Format([YourDateField],"w")
Use criteria of 1 Or 7
This pulls the weekends. Delete these days.
Use an update query to fill in 8:00:00 and 9:00:00 in each StartTime and
EndTime field.
Open the table in design view and create a primary key from your three
fields. This way there will be not duplicates.
Next use an append query that appends the date field and adds one hour to
each of the time fields.
Repeat this last query eleven times to append each hour to the table. On
the second time and thereafter you will get error messages as there are two
records with the same date and you are appending a new hour to each. One hour
to 9:00 is ok but the one hour to the existing 8:00 will give an error as
9:00 exist.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top