|
-
Oct 12th, 2023, 06:14 AM
#1
Thread Starter
Addicted Member
SQL Query for getting available locations within 2 dates in Access SQL
I have a table with locations and the dates when they are occupied in Access mdb database.
CREATE TABLE `locations` (
`LocationID` int(11) NOT NULL,
`Location` varchar(255) NOT NULL,
`StartDate` date NOT NULL,
`EndDate` date NULL DEFAULT NULL
)
INSERT INTO `locations` VALUES (1, 'Venue A', '2023-10-01', '2023-10-10');
INSERT INTO `locations` VALUES (2, 'Venue B', '2023-10-15', '2023-10-20');
INSERT INTO `locations` VALUES (3, 'Venue C', '2023-10-05', '2023-10-12');
INSERT INTO `locations` VALUES (4, 'Venue D', '2023-10-08', NULL);
INSERT INTO `locations` VALUES (5, 'Venue E', '2023-10-25', NULL);
INSERT INTO `locations` VALUES (6, 'Venue F', '2023-10-21', '2023-10-25');
INSERT INTO `locations` VALUES (7, 'Venue G', '2023-10-30', '2023-11-05');
INSERT INTO `locations` VALUES (8, 'Venue H', '2023-11-01', '2023-11-10');
INSERT INTO `locations` VALUES (9, 'Venue I', '2023-11-15', NULL);
INSERT INTO `locations` VALUES (10, 'Venue J', '2023-12-01', '2023-12-05');
INSERT INTO `locations` VALUES (11, 'Venue K', '2023-12-10', '2023-12-20');
INSERT INTO `locations` VALUES (12, 'Venue L', '2023-12-15', NULL);
What would be the query to get locations that are free between 2 dates. For example, from '2023-10-21' and '2023-11-20' the result would be:
Location
Venue A
Venue B
Venue C
Venue J
Venue K
Venue L
My projects:
Virtual Forms
VBA Telemetry
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|