Solved

MS Access - return list of dates with no record

Posted on 2009-05-16
2
235 Views
Last Modified: 2013-11-27
I have a SQL Server database with an Access front end.  The database is of event bookings.  I would like to design a query that lists Saturday and Sunday dates with no events booked.

The end object is to publish it to the web so I can create last minute deals.
0
Comment
Question by:les28
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24404300
what you need is a calendar table, with (all) the dates.
once you have that (and believe me, that table WILL serve later also), you can fetch, from there, easily all the dates that are a saturday/sunday:
datepart(weekday, your_date_field) in (6,7)
the values 6 and 7 are if the DATE_FIRST setting is set to monday.

once you have that query, you just left join to your table.
"just" fill in your table and column names as fit:
SELECT cd.date_value
  FROM your_calendar_table cd
  LEFT JOIN your_boooking_table b
    ON b.booking_date = cd.date_value
 WHERE datepart(weekday, cd.date_value) in (6,7)
   AND b.booking_date IS NULL  ---- < this is the part that will make the query to return the dates with no bookings

Open in new window

0
 
LVL 1

Author Closing Comment

by:les28
ID: 31582284
Thanks very much.  I'll give it a try
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question