March 9, 2009 at 9:55 pm
Try this statement
select * from tbldeals
--where trade_date = '2009-03-06 00:00:00'
where convert(datetime,(convert(int,trade_date,101)))= '2009-03-06 00:00:00'
ARUN SAS
March 11, 2009 at 11:37 am
And why not do this instead:
DECLARE @ld_TestDate datetime
SET @ld_TestDate = CONVERT(datetime, '2009-03-06 00:00:00')
SELECT * FROM tbldeals
WHERE trade_date >= @ld_TestDate
AND trade_date < @ld_TestDate + 1
i.e. do the conversion ONCE and allow the server to use the index (if any) on column trade_date
March 11, 2009 at 11:58 am
Nice it would be if feedback OP would provide.
March 19, 2009 at 4:40 am
Lynn Pettis (3/11/2009)
Nice it would be if feedback OP would provide.
Hee! True. @=)
Everytime I run into this issue, it's because I'm either using an = sign with a date comparison when there's a time attached (IE, Mydate = '01/01/2009' when the datetime is 2009-01-01 23:52:00) or when the field is not a true datetime column / I'm using the wrong datetime format for my search.
But, until we hear back from the OP, we will never know if any of our suggestions worked.
March 19, 2009 at 3:53 pm
Just a simple attempt...
If you execute the following script. Do you see the milliseconds? Maybe your SSMS does not show them in its output. Do you use grid or text output?
;WITH test (id, dt) AS
(
SELECT 1, GETDATE()
UNION ALL SELECT 2, '2009-03-19T12:34:56.787'
)
SELECT * FROM test
Greets
Flo
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply