Creating instances of dates based on days of the week 
Author Message
 Creating instances of dates based on days of the week

I have an input form that collects a start date, end date,
and days of the week (check boxes).  I would like to auto
create dates in a table based on this information.  For
example if the start date is 01/01/03 and the end date is
02/01/03 and I have selected Monday and Wednesday, I would
like to populate the table with the following dates:

01/01/03
01/06/03
01/08/03
01/13/03
01/15/03
01/20/03
01/22/03
01/27/03
01/29/03

Any help would be greatly appreciated...

thanks in advance

Jay Easley



Sat, 05 Nov 2005 21:25:54 GMT  
 Creating instances of dates based on days of the week
Hi Jay

The key thing you need here is the Weekday function. It takes a date
and returns the day of the week that date is, as a number.

basic pseudo code would be.
(note, this code hasn't been anywhere near a compiler, all completely
off the top of my head)

redim InsertionDays(1 to 7) as boolean
InsertionDays(1) = chkSunday.value
InsertionDays(2) = chkMonday.value
'... for all days

temp_date = start_date
while temp_ date <= start_date
    if InsertionDays(Weekday(temp_date)) then
        AddDateToList(temp_date)
    end if
    temp_date = dateadd("d",1,temp_date)
wend

where AddDateToList does whatever it is you need to do to get the date
into the table you want it in. More than likely a Currentdb.execute
"INSERT INTO ..." statement

HTH
Dan

Quote:

> I have an input form that collects a start date, end date,
> and days of the week (check boxes).  I would like to auto
> create dates in a table based on this information.  For
> example if the start date is 01/01/03 and the end date is
> 02/01/03 and I have selected Monday and Wednesday, I would
> like to populate the table with the following dates:

> 01/01/03
> 01/06/03
> 01/08/03
> 01/13/03
> 01/15/03
> 01/20/03
> 01/22/03
> 01/27/03
> 01/29/03

> Any help would be greatly appreciated...

> thanks in advance

> Jay Easley



Sun, 06 Nov 2005 08:13:35 GMT  
 Creating instances of dates based on days of the week
oops, I meant to say

while temp_ date <= end_date

rather than start_date :-)

Quote:

> Hi Jay

> The key thing you need here is the Weekday function. It takes a date
> and returns the day of the week that date is, as a number.

> basic pseudo code would be.
> (note, this code hasn't been anywhere near a compiler, all completely
> off the top of my head)

> redim InsertionDays(1 to 7) as boolean
> InsertionDays(1) = chkSunday.value
> InsertionDays(2) = chkMonday.value
> '... for all days

> temp_date = start_date
> while temp_ date <= start_date
>     if InsertionDays(Weekday(temp_date)) then
>         AddDateToList(temp_date)
>     end if
>     temp_date = dateadd("d",1,temp_date)
> wend

> where AddDateToList does whatever it is you need to do to get the date
> into the table you want it in. More than likely a Currentdb.execute
> "INSERT INTO ..." statement

> HTH
> Dan


> > I have an input form that collects a start date, end date,
> > and days of the week (check boxes).  I would like to auto
> > create dates in a table based on this information.  For
> > example if the start date is 01/01/03 and the end date is
> > 02/01/03 and I have selected Monday and Wednesday, I would
> > like to populate the table with the following dates:

> > 01/01/03
> > 01/06/03
> > 01/08/03
> > 01/13/03
> > 01/15/03
> > 01/20/03
> > 01/22/03
> > 01/27/03
> > 01/29/03

> > Any help would be greatly appreciated...

> > thanks in advance

> > Jay Easley



Sun, 06 Nov 2005 12:57:27 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Date / Same date or first day of week

2. Date of first day of week?

3. A five day week for date calculation

4. Find first day of week for date entered

5. Get the day of the week from a date in the text

6. Get the day of the week from a date in the text

7. Extracting a date from year,week,day

8. Help with extracting the day of the week out of the date

9. rookie question re: Date/Day of week

10. Dates, weeks and days

11. Date of the first day of the Week

12. how to set date to first day of week

 

 
Powered by phpBB® Forum Software