Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Listing Dates
Gary Gunn 
    
3 years ago
I have a small database that I track Festivals with and On my homepage I have listed the upcoming shows for the next 2 weeks. My problem is, I have an event start date and an event end date. How do I get it to list the dates between the start and end as part of that festival?
Dan Jackson  @Reply  
            
3 years ago
Use this in your query as a criteria in your date field
>=Date() AND <=Date()+14

This literally says "Show me all records that are GREATER THAN or EQUAL TO today AND LESS THAN or EQUAL TO 14 Days From Today"

This includes both end points, I.E. Today and the 14th day. To remove either of these, just get rid of the corresponding =

Check out Date Math
Dan Jackson  @Reply  
            
3 years ago
I just read the part about you have the start and end date. The only different is

In your StartDate criteria, put >=Date()

and then, ON THE SAME ROW, under EndDate, Put <=Date()+14
Dan Jackson  @Reply  
            
3 years ago

Gary Gunn OP  @Reply  
    
3 years ago
I am the worst at explaining things. I actually have a very similar query that works like this except I would like it to list the show on both days or all 3 days that it will be happening. So what I'm trying to say is that The way it is, it only lists it on the 1st day. Say April 20. But the show runs for 3 days. How do I have it relist for the other 2 days or more without manually putting in those dates. so that it shows the same event on the 21st and 22nd. Thanks for your patience and understanding.
Dan Jackson  @Reply  
            
3 years ago
I know the feeling. It's easy to see what you want but try to put it into words - that's tricky!

So what you're saying is, if an event runs for three days, you want to see three entries - one for each day?
Dan Jackson  @Reply  
            
3 years ago
I asked ChatGPT. I'm not sure i quite follow its method but I'm not at my computer at the moment so give this a go and let me know how you get on

=========================

ME :  
In Microsoft Access, I have two fields - a start date and an end date. How do I list duplicate records, one for each day in the range between start date and end date?

ChatGPT :

You can use a query in Microsoft Access to generate a list of duplicate records, one for each day in the range between the start date and end date. Here are the steps:

Create a new query in design view.
Add the table that contains the start date and end date fields.
Add the start date and end date fields to the query design grid.
Add a calculated field to the query design grid by entering the following expression in a blank field:
DateSerial(Year([Start Date]),Month([Start Date]),Day([Start Date])+[Number])

This expression creates a new date by adding the number of days between the start date and end date to each day between the start date and end date.

In the same calculated field, enter the following expression in the "Number" field:
[qry_Dates].[Number]

This expression references a new query that you will create in the next step.

Create a new query called qry_Dates in design view.
Add the following fields to the qry_Dates query:
A field called "Number" with the data type "Number".
A field called "Dummy" with the data type "Text".
In the "Number" field of the qry_Dates query, enter the following expression:
SELECT DISTINCT Abs([id] Mod 10000) AS N FROM MSysObjects
This expression generates a list of numbers from 0 to 9999 that you can use to generate dates in the calculated field of the first query.

In the "Dummy" field of the qry_Dates query, enter any text value, such as "x".
Save and close the qry_Dates query.
In the first query design grid, join the start date and end date fields to the qry_Dates query on the "Number" field.
Run the query to generate a list of duplicate records, one for each day in the range between the start date and end date.
Note that if you have a large date range, this query can generate a large number of records, so you may want to limit the date range or add additional criteria to the query to filter the results.
Gary Gunn OP  @Reply  
    
3 years ago
Sorry for the late reply, I have been tied up with work. Anyways, I cannot seem to get this to work. I do get an alarm that says "At most one record could be returned by this subquery". Assuming I set it up correctly. If I run just the 2nd query "qry_Dates" I get no info in the columns. So I'm thinking I'm not setting it up correctly. Could you elaborate on it in some way? Thanks Dan
Dan Jackson  @Reply  
            
3 years ago
Ok, that method offered by ChatGPT was nuts! Took a few attempts but found a good way -

First thing you'll need is your table with a list of the events, StartDate and EndDate Fields. See Below (Mine is called _NewTableT. Replace this with the name of your main table):




Next, create a new table with just one field called Number (Can make it a number type. No Primary Key Needed). Enter a new record and add a list of numbers. Go as far as the number of days your longest event will be.



Now we are going to create the query to list the dates:



Add your main table and the Number table (Note i didn't need to make any joins) and add all required fields
On a new field, give it an Alias (Like I called mine DayStep) and use this code
DayStep: DateAdd("d", Number,StartDate) (Notice I didn't use the square brackets or table name here - ChatGPT uses bad naming convensions!)
Add Number from the "NumberOfDays" table and put this into the criteria
<=DateDiff("d",StartDate,EndDate)

Et Voilà!



Note on sorting: Remember it sorts from left to right so i'd recommend, in your case, sorting by start date first (This will list the events in order of start date AND group event dates together) and THEN by Day Step.

Gary Gunn OP  @Reply  
    
3 years ago
Dan Jackson, you are the MAN! It works perfectly! I did have one problem that if you could explain I would be thrilled about. In the criteria "=DateDiff("d",StartDate,EndDate" it added quotation marks and gave me an alarm for wrong criteria. I changed it to "[]" around it and it works perfectly. any idea?
Dan Jackson  @Reply  
            
3 years ago
Quotations are for string values. Like literal text. If you put "StartDate", access will just use the word Startdate.
Square brackets are used to tell access it's a field

In this case, "StartDate" will be interpreted as STARTDATE. [StartDate] will be interpreted as whatever is in your Startdate field

This is the reason why Rick strongly recommends no spaces in field names. If you have a field called StartDate and you put in StartDate, access will automatically know you are referring to the field without having to use the square brackets. If you use spaces in your field names (As ChatGPT did), you have to enclose ALL field names in Square Brackets like [Start Date]. Whenever you are using quotes, Access will always treat it "AS IS" and not interpret in any way

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/30/2026 7:12:53 AM. PLT: 0s