Post Author: danderson
CA Forum: Data Connectivity and SQL
Hi
I am using a command to extract data from history tables of data. I have got the query with a fixed time variable (ie now - 12 hours) but I cant seem to get it to work passing parameters in. This is what works so far:
SET QUOTED_IDENTIFIER OFFSELECT * FROM OpenQuery(INSQL, "SELECT DateTime = convert(nvarchar, DateTime, 113), [T1 Distance], [T1 kWh], [T1 Speed] FROM Runtime.dbo.AnalogWideHistory WHERE wwVersion = 'Latest' AND wwRetrievalMode = 'Cyclic' AND wwResolution = 15000 AND DateTime >= DateAdd(hh,-12,GetDate()) AND DateTime <= GetDate()")
I have done it like this on similar queries, but I can't seem to crack it on this one. This is what I have tried (in various forms!!!) that doesnt work
SET QUOTED_IDENTIFIER OFFSELECT * FROM OpenQuery(INSQL, "SELECT DateTime = convert(nvarchar, DateTime, 113), [T1 Distance], [T1 kWh], [T1 Speed] FROM Runtime.dbo.AnalogWideHistory WHERE wwVersion = 'Latest' AND wwRetrievalMode = 'Cyclic' AND wwResolution = 15000 AND DateTime >= {?StartDate} AND DateTime <= {?EndDate}")
I then have a date / time variable for StartDate and EndDate
Can anyone give me any hints??
Thanks
Dave A