Storing Recurring dates in a DB

sinclac
10-11-2004, 11:16 PM
Hello,

I am stuck on how to do somthing in VB with an Access database.
Using JET (Access) and DAO

I am writing a program to schedule job for landscapers (A routing program)

Here is the problem i can write all the job info to the DB except i'm not sure how i should write all the recurring dates.

Job #1 on dates 10-1-2004, 10-7-2004, 10-14-2004, 10-21-2004, 10-29-2004 and so on this can go on for years.


I would appreciate any help you can give.

Chuck

webbone
10-11-2004, 11:27 PM
What you'll want to do will, of course, depend on what information you are storing in your database. If you are storing individual events then what you probably want to do is something like this (pseudo code):


CreateNewEvents:
Get StartDate, EndDate, Frequency from user
Convert Frequency into # of days (i.e. weekly = 7, etc.)

CurrentDate = StartDate
Do while CurrentDate <= EndDate
StoreNewEvent(CurrentDate)
CurrentDate = CurrentDate + days to next event
Loop

You might also want to look at using the DateAdd() (http://msdn.microsoft.com/library/en-us/vbenlr98/html/vafctDateAdd.asp) and DateDiff() (http://msdn.microsoft.com/library/en-us/vbenlr98/html/vafctDateDiff.asp) functions to easily allow you to deal with monthly events and leap years, etc.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum