user2799436
user2799436

Reputation: 36

Datetime operation in where clause of a SQL statement

I have written a query like

select *  
from tbltransaction 
where transactiondate < CAST('2014-10-30 22:09:59.570' AS DATETIME)

In this query the transactiondate should be less than 2014-10-30 00:00:00.000 is only displayed the transactiondate like 2014-10-30 12:09:59.570, 2014-10-30 20:09:59.570, 2014-10-30 02:09:59.570 are not displayed. Please help me on this.

Upvotes: 0

Views: 40

Answers (1)

Dgan
Dgan

Reputation: 10275

try like this:

You Need to Use Same DateType on the both side of Filter Column like as below DATETIME

select * fom tbltransaction where 
CAST(transactiondate  as DATETIME) < 
CAST('2014-10-30 22:09:59.570' AS DATETIME)

Upvotes: 2

Related Questions