Reputation: 2299
I tried get all records between after 00:00 and now time
E.g Between 21.02.2014 00:01 and 21.02.2014 10:41(now time)
Select * from TableName Where Time >=??? and Time < Getdate()
Upvotes: 0
Views: 89
Reputation: 1632
Select * from TableName Where Time between cast(GETDATE() as DATE) and Getdate()
Upvotes: 0
Reputation: 32697
If you're on SQL 2008 or later, you can do something like the ff:
select *
from tablename
where cast([Time] as date) = getdate()
and cast([Time] as time) >= '10:41'
This isn't going to be super performant as the cast
makes the predicate non-SARGable. If this is something that you envision doing frequently, you can add persisted computed columns to your table that do the casts for you.
Upvotes: 0
Reputation: 2299
Select * from TableName Where DateDiff(day,TimeColumn,getdate())
between 0 and 0
Upvotes: 0