Solved

MS Access - return list of dates with no record

Posted on 2009-05-16
2
197 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
2 Comments
 
LVL 142

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now