Flux : Using import timezone in external (nodered) query

In Fluxdb 2.6.1 this query returns data in local time

import “timezone”

option location = timezone.location(name: “Europe/London”)

from(bucket: “AshTree_AAGSolo_2days”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “aagsolodata”)
|> filter(fn: (r) => r[“Category”] == “Ambient temp”)
|> drop(columns: [“_start”, “_stop”, “_field”, “_measurement”])

but in nodered this query returns data in UTC

‘import “timezone”\n’ +
‘option location = timezone.location(name: “Europe/London”)\n’ +
‘from(bucket: “AshTree_AAGSolo_2days”)’ +
'|> range(start: ’ + stimestart + ', stop: ’ + stimenow + ‘)’ +
‘|> filter(fn: (r) => r[“_measurement”] == “aagsolodata”)’ +
‘|> filter(fn: (r) => r[“Category”] == "’ + category + ‘“) ’ +
'|> drop(columns: [”_start", “_stop”, “_field”, “_measurement”])’

I need the data in local time. How do I get the data in local time, please ?

I am really stuck on this. To ask the question in another way. Is it possible to call

import “timezone”
option location = timezone.location(name: “Europe/London”)

outside of Flubdb ?

I have also tried

‘import "timezone"option location = timezone.location(name: “Europe/London”)from(bucket: “AshTree_AAGSolo_2days”)’ +
'|> range(start: ’ + stimestart + ', stop: ’ + stimenow + ‘)’ +
‘|> filter(fn: (r) => r[“_measurement”] == “aagsolodata”)’ +
‘|> filter(fn: (r) => r[“Category”] == "’ + category + ‘“) ’ +
'|> drop(columns: [”_start", “_stop”, “_field”, “_measurement”])’

This also returns UTC data

Hi @IanH

This is just an idea that may not even work, but if running the Flux query from NodeRED does indeed not retrieve the data in the desired timezone, then maybe send the UTC data (retrieved via NodeRED) and send through a function node that will adjust the timestamp values.

Thank you. That may be my only option if I can’t get “import” and “option” to work.