I want to select from a SQL Server table where a datetime field is > than midnight of the current date.
I'm using the following but would like to ask if there is a more efficient way to do it?
WHERE start_time > (Select DATEADD(d,0,DATEDIFF(d,0,GETDATE())))
If you convert or cast the current date to a date instead of datetime, I believe you can use that in your WHERE because the date data type is set to midnight:
WHERE start_time > CONVERT(date, GETDATE())
OR
WHERE start_time > CAST(GETDATE() AS date)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With