By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table table1 (calendar_day varchar(20), plant varchar(3), stocks int)
insert into table1 (calendar_day, plant, stocks) values
('20240316', 'ABC', 100),
('20240511', 'DEF', 850),
('20240508', 'GHI', 520),
('20240105', 'JKL', 222),
('bla bla bla', 'GGG', 222)
select * from table1
calendar_day | plant | stocks |
---|---|---|
20240316 | ABC | 100 |
20240511 | DEF | 850 |
20240508 | GHI | 520 |
20240105 | JKL | 222 |
bla bla bla | GGG | 222 |
declare @value varchar(6) = convert(char(6), getdate(), 112)
select t.calendar_day,
t.plant,
t.stocks
from table1 t
where t.calendar_day like @value + '%'
calendar_day | plant | stocks |
---|---|---|
20240511 | DEF | 850 |
20240508 | GHI | 520 |
drop table table1