Need Confirmation I understand how TimeZones work

Hi,

I just need someone to confirm that I understand this correctly, or correct me if I am wrong :slight_smile:

Using TZ() in a query doesn’t alter the output of a query but the times that the query runs, for example, if I run this;

SELECT sum(“rain”) FROM “enviro”.“autogen”.“Shed” WHERE time >= ‘2020-08-19’ AND time < ‘2020-08-20’ GROUP BY time(1h)

I get this data

ResultSet({’(‘Shed’, None)’: [{‘time’: ‘2020-08-19T00:00:00Z’, ‘sum’: None}, {‘time’: ‘2020-08-19T01:00:00Z’, ‘sum’: None}, {‘time’: ‘2020-08-19T02:00:00Z’, ‘sum’: None},

But if I run this;

SELECT sum(“rain”) FROM “enviro”.“autogen”.“Shed” WHERE time >= ‘2020-08-19’ AND time < ‘2020-08-20’ GROUP BY time(1h) tz(‘Europe/London’)

ResultSet({’(‘Shed’, None)’: [{‘time’: ‘2020-08-18T23:00:00Z’, ‘sum’: None}, {‘time’: ‘2020-08-19T00:00:00Z’, ‘sum’: None}, {‘time’: ‘2020-08-19T01:00:00Z’, ‘sum’: None},

Note the first result in the second one is an hour before the first one.

Obviously I’ve truncated the results because the rest isn’t relevant to my question.

Using TZ alters the times that are used to run the where clause on the query and it does not alter the timezone of the outputted data.

I worked this out because where I have data isn’t changed by using the TZ, just the start and stop time of the results.

I originally thought that using TZ would show the results in the chosen TZ not change the selection criteria to the chosen TZ.

If my new understanding is correct I, therefore, need to adjust for TZ in my graphing and not when querying the data.

I hope this makes sense :slight_smile:

J

I’m not as familiar with v1 as with v2 influxdb, but yes I believe that is correct . Time stamps are in rfc3339, and any charting tools need to adjust for that

Thanks for the confirmation, I’ve managed to get it my TZ issue resovled, wish I had come to this conclusion earlier :slight_smile:
J