I wanted to use SQL query to fetch tag history data of particular tag so I've used following query:
SELECT tagid, intvalue, t_stamp, DATEADD(s,t_stamp/1000,'1970-01-01 00:00:00') as Time_Stamp FROM sqlt_data_1_2023_04 where tagid = 4460
and DATEADD(s,t_stamp/1000,'1970-01-01 00:00:00') >= '2023-04-28 12:00:00.000'
and DATEADD(s,t_stamp/1000,'1970-01-01 00:00:00') < '2023-04-29 00:00:00.000'
order by [t_stamp]
Now my question is the timestamp I get from above conversion in the result is with respect to UTC time zone or gateway time zone?
This is going to be terribly inefficient. Instead of converting each row's timestamp in the WHERE clause, convert the constants to UTC milliseconds. The WHERE clause will run much, much faster.