SQL Query to check ALL days exist between a date range
Posted
by CL4NCY
on Stack Overflow
See other posts from Stack Overflow
or by CL4NCY
Published on 2010-03-10T21:53:20Z
Indexed on
2010/03/23
18:33 UTC
Read the original article
Hit count: 349
Hi, I have a table of Prices with a start date, end date and price. I want a search to pass in a date range and return whether a price exists for all days in that range. The date range can span multiple prices, just not have any gaps in between.
Is this possible?
Prices
startDate datetime
endDate datetime
price
DECLARE @startDate datetime = '2010-04-01',
@endDate datetime = '2010-04-30'
SELECT * FROM Prices WHERE @startDate BETWEEN startDate AND endDate...
© Stack Overflow or respective owner