May 19, 2006 at 6:32 am
May 19, 2006 at 7:33 am
Dean,
tough to say what the problem is here.
Try setting the value of a second date parameter to dateadd(Hour, 2....) beforehand. As in the following example. See if that makes a difference.
How big is this table by the way?
DECLARE
@Triggered_Datetime [datetime],
@Triggered_Price [money],
@TwoHour_Datetime [datetime]
SET @Triggered_Datetime = '2006-03-01 01:03:59.000'
SET @Triggered_Price = 1.2017
SET @TwoHour_Datetime = Dateadd(Hour,2,@Triggered_Datetime)
SELECT TOP (1) Ticks.Tick_Identity, ticks.Tick_DateTime
FROM Ticks
WHERE Ticks.Tick_Price = @Triggered_Price AND
Ticks.Tick_DateTime BETWEEN @Triggered_Datetime AND
@TwoHour_Datetime
ORDER BY Ticks.Tick_Identity
May 19, 2006 at 9:34 am
i've seen this behaviour on betweens before.
try using where Ticks.Tick_Price = @Triggered_Price AND
Ticks.Tick_DateTime >= @Triggered_Datetime AND
Ticks.Tick_DateTime<=(dateadd......
no idea why it fixed the problem but it did - possibley something to do with the arguments being sargable
MVDBA
May 19, 2006 at 9:41 pm
Thanks for your reply’s Mike and Karl,
Unfortunately neither suggestions make any difference.
It is a big file, and TOP (1) & ORDER BY have their own nuances, but its confusing that the code works when I use actual values other than the variables.
My feeling is that it is a CAST issue, but the datatype in the table is definitely datetime.
Back to the drawing board!
Regs
DeanB
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply