create table #providesampledata(orderid int, order_date varchar(100),
order_name varchar(50))
--this part is imitating your varchar data type order_date
insert into #providesampledata
select 1 , convert(varchar(20), getdate(), 103) + ' ' +
convert(varchar(20), dateadd(hh,1,getdate()), 114) , 'chicken wings' union
select 2 , convert(varchar(20), getdate(), 103) + ' ' +
convert(varchar(20),dateadd(hh,2,getdate()), 114) , 'steak' union
select 3 , convert(varchar(20), getdate(), 103) + ' ' +
convert(varchar(20), dateadd(hh,3,getdate()), 114) , 'eggs' union
select 4 , convert(varchar(20), getdate(), 103) + ' ' +
convert(varchar(20), dateadd(hh,4,getdate()), 114) , 'bread' union
select 5 , convert(varchar(20), getdate(), 103) + ' ' +
convert(varchar(20), dateadd(hh,5,getdate()), 114) , 'milk' union
select 6 , convert(varchar(20), getdate(), 103) + ' ' +
convert(varchar(20), dateadd(hh,6,getdate()), 114) , 'welding' union
select 6 , convert(varchar(20), getdate(), 103) + ' ' +
convert(varchar(20), dateadd(hh,9,getdate()), 114) , 'popsicles' union
select 6 , convert(varchar(20), getdate(), 103) + ' ' +
convert(varchar(20), dateadd(hh,11,getdate()), 114) , 'salad'
;with cte
as
(
--below we are converting that varchar order_date to proper datetime data type using
-- CONVERT with 103 as stated above by denis_the_thief
--https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-2017
select CONVERT(datetime, order_date, 103) as order_date, orderid, order_name
From #providesampledata
)
select *
From cte
where order_date > '2018-05-15' and order_date <= '2018-05-15 14:00:00'
drop table #providesampledata