auto fill a date series in make-table query

T

Tim

Anyone know how I can auto fill a date series using a make-
table query with a start date and Date(). For example,
generate a table starting with an identified start date,
looking something like

7/5/03
7/6/03
7/7/03
7/8/03
7/9/03
7/10/03, etc, up to the present date.

The beggining date will vary each time the make query is
run, but the end date will always be the present date.

Thanks,
Tim
 
A

Allen Browne

Function MakeDates()
Dim dt As Date
Dim rs As DAO.Recordset

Set rs = DBEngine(0)(0).OpenRecordset("tblDate")
With rs
For dt = #1/1/2003# To #12/31/2003#
.AddNew
!WotDate = dt
.Update
Next
End With
rs.Close
Set rs = Nothing
End Function
 
J

John Vinson

Anyone know how I can auto fill a date series using a make-
table query with a start date and Date().

An auxiliary table will do this neatly: have a table named Num with
one long integer field N, with values from 0 to the largest number of
days you'll ever need. This table has many uses, I have one in all my
databases now.

Base your MakeTable query on Num; include a calculated field

DateAdd("d", [N], [Enter start date:])

with a criterion of

<= Date()
 

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