I have a statement setup as follows:
SELECT *
FROM Events
WHERE CAST('6/6/2013 10:14:30 PM' AS DATETIME) < EventTime
Right now, it returns every event including those occurring at that time, which means I have to process the events after the query. Is there a way to setup this query so that it only returns events with an EventTime that is greater than the given string datetime?
Basically, the < operator seems to be treated as <=, and I don't want this.
You could use DATEDIFF function of sql server, like such:
SELECT *
FROM Events
WHERE DATEDIFF(Second, Cast('6/6/2013 10:14:30 PM' AS DATETIME) , @EventTime) < 0
--^^ this can be changed to what ever accuracy you want
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