Select Date between Two Date Columns

This is how to run a SQL Query where you have two date columns and like to see if your date falls between those columns;

SELECT * FROM FiscalCalendarRef
WHERE 1=1
AND '2021-09-13' BETWEEN StartDate AND EndDate

If EndDate column is defined as NULL, you can change it like this;

SELECT * FROM FiscalCalendarRef
WHERE 1=1
AND '2021-09-13' BETWEEN StartDate AND COALESCE(EndDate, GETDATE())

FavoriteLoadingAdd to favorites
Spread the love

Author: Shahzad Khan

Software developer / Architect