Solved

MS Access - return list of dates with no record

Posted on 2009-05-16
2
229 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 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

680 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