i have my database date stored in smalldatetime. now, if i need to filter the results based on(say today's date equals the date in database), what is the best way to do it?
select * from tbl Emp where Emp.date = cast(getdate() as smalldatetime)
//this will not match the date
the other way i found but not sure if casting the date in table affects performance like:
select * from tbl Emp where cast(Emp.date as date) = cast(getdate() as date)
This method is accurate:
This method is accurate and can use an index:
The
+ 1
is a convenience in SQL Server that adds one day to adatetime
value. But, you can also use