DROP TABLE IF EXISTS b;
CREATE TABLE b(
MajDate smalldatetime
);
INSERT INTO b(MajDate) VALUES
(try_convert(smalldatetime,'2016-11-30 11:23:00')),
(try_convert(smalldatetime,'2021-07-07 11:07:00')),
(try_convert(smalldatetime,'2021-07-07 11:07:00'))
select
b.MajDate,
CASE WHEN b.MajDate BETWEEN '2021-07-01 00:00:00' AND '2021-08-01 00:00:00'
THEN 'YES'
ELSE 'NO'
END AS InRange
From b;
What am I doing wrong ?
Desired Output: Column InRange should contain YES for two last rows.