473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

List dates between dates

My dbase has the start date and end date of each visit. How can I ask
Access to list the day of the week of the start (easy), end (easy) and,
more importantly, the dates of the visit itself - ie list the dates
between the start and end date. Basically I am doing a day of the week
analysis and need to know which day of the week is busiest.

Aug 1 '06 #1
1 15511
The dates have to come from somewhere, so create a table of dates, and you
can use a Cartesian Product query to list each date in each range.

1. Create a table with one field named TheDate, type Date/Time.
Save the table as tblDate.
You can use the function below to populate it with all the years of dates
your data will cover.

2. Create a query that uses your existing table, and tblDate.
There must be no line joining the 2 tables in the upper pane of query
design.
It is the lack of any join that gives every possible combination.

3. In query design, drag TheDate from tblDate into the grid.
In the Criteria row under this field, enter:
Between [Table1].[StartDate] And [Table1].[EndDate]
Substitute the real names for your table and fields.
This restricts it to only dates in the range.
Save the query.

You can now create a report listing all the dates from the query.

Here is the function to save typing all the dates by hand.
To use it open the Immediate Window (Ctrl+G), and enter:
? MakeDates(#1/1/2000#, #12/31/2019#)
or whatever date range you want to cover.

Function MakeDates(dtStart As Date, dtEnd As Date) As Long
Dim dt As Date
Dim rs As DAO.Recordset

Set rs = DBEngine(0)(0).OpenRecordset("tblDate")
With rs
For dt = dtStart To dtEnd
.AddNew
!TheDate = dt
.Update
Next
End With
rs.Close
Set rs = Nothing
End Function
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<pi**************@mac.comwrote in message
news:11**********************@s13g2000cwa.googlegr oups.com...
My dbase has the start date and end date of each visit. How can I ask
Access to list the day of the week of the start (easy), end (easy) and,
more importantly, the dates of the visit itself - ie list the dates
between the start and end date. Basically I am doing a day of the week
analysis and need to know which day of the week is busiest.

Aug 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: PW | last post by:
<rant> Sorry guys, but I just have to whinge. Dates in ASP are a total pain in the butt! I seem to get caught out so many times. I realise its my own fault, but going from the posts in this...
0
by: Tony | last post by:
Aloha, I have a problem that I can't think of a (easy) solution for. I'm building a web app (asp/access) that will allow people to book a cruise on a 24 passenger yacht that goes around the...
5
by: jnikle | last post by:
I have two completely unrelated tables, one for reviews and another for pay periods. The reviews table has a review date in it, and the pay periods table is just a list of the beginnings of pay...
18
by: PC Datasheet | last post by:
An Access user saw my name in a newsgroup and sent me a request for help on a project. As part of the project, a list of the dates in a month was needed. For anyone needing a list of dates in a...
1
by: sang | last post by:
Hi how to list the inserted dates by week,month and year. That is how to select the dates by past one week. similarly the month and year of the particular filed. Thanks in Advance Sang
5
by: romanisa | last post by:
Hii friends I need to calculate the age median from the given dates of birth in an employee database in MS SQl. Please help... Roma
4
by: Charlote | last post by:
Hello, I am a beginner in python, and have a question.. I need to create a list of all dates between two dates.. Lets say beggining date= 2008-1-15 enddate= 2008-2-20 how do I...
1
by: Matt Lowrance | last post by:
I have created an object that has a number of properties, that I am now trying to simply databind to a form. I am using the data designer to do it and just dragging and dropping the items onto the...
2
by: Luka Djigas | last post by:
Hello everyone, please, I need your help. I'm new to python, so I don't know if this will seem like a stupid question to some of you ... I have a need to write to a file (or just print on...
1
by: meyis | last post by:
hai i am meyis i need a jsp program code for date generation.(mssql-back end) Fields are fromdate and todate both field are datetime datatype. Button:-save,cancel,exit both dates are given by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.