diff --git a/content/influxdb/cloud-dedicated/query-data/sql/basic-query.md b/content/influxdb/cloud-dedicated/query-data/sql/basic-query.md index e94de7e4a..eaf1d1192 100644 --- a/content/influxdb/cloud-dedicated/query-data/sql/basic-query.md +++ b/content/influxdb/cloud-dedicated/query-data/sql/basic-query.md @@ -131,7 +131,33 @@ WHERE AND time <= '2022-01-01T20:00:00Z' ``` {{% /influxdb/custom-timestamps %}} +{{% /expand %}} +{{% expand "Query data using a time zone offset" %}} + +To query data using a time zone offset, use the +[`AT TIME ZONE` operator](/influxdb/cloud-dedicated/reference/sql/operators/other/#at-time-zone) +to apply a time zone offset to timestamps in the `WHERE` clause. + +{{% note %}} +Timestamp types in InfluxDB always represent a UTC time. `AT TIME ZONE` returns +a UTC timestamp adjusted for the offset of the specified time zone. +Timestamps in the `time` column are not updated. +If you need to display the timestamps in your current timezone, this should be handled +client-side. +{{% /note %}} + +{{% influxdb/custom-timestamps %}} +```sql +SELECT + * +FROM + home +WHERE + time >= '2022-01-01 00:00:00'::TIMESTAMP AT TIME ZONE 'America/Los_Angeles' + AND time <= '2022-01-01 12:00:00'::TIMESTAMP AT TIME ZONE 'America/Los_Angeles' +``` +{{% /influxdb/custom-timestamps %}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/influxdb/cloud-dedicated/reference/sql/_index.md b/content/influxdb/cloud-dedicated/reference/sql/_index.md index cbf9e4c97..3b573302d 100644 --- a/content/influxdb/cloud-dedicated/reference/sql/_index.md +++ b/content/influxdb/cloud-dedicated/reference/sql/_index.md @@ -195,9 +195,10 @@ Bitwise operators perform bitwise operations on bit patterns or binary numerals. ### Other operators -| Operator | Meaning | Example | Result | -| :------: | :------------------- | :---------------------- | :------------ | -| `\|\|` | Concatenates strings | `'Hello' \|\| ' world'` | `Hello world` | +| Operator | Meaning | Example | Result | +| :------------: | :----------------------- | :-------------------------------------------------------------------------------------- | :------------ | +| `\|\|` | Concatenates strings | `'Hello' \|\| ' world'` | `Hello world` | +| `AT TIME ZONE` | Apply a time zone offset | _[View example](/influxdb/cloud-dedicated/reference/sql/operators/other/#at-time-zone)_ | | ## Keywords @@ -209,6 +210,7 @@ ALL ANALYZE AS ASC +AT TIME ZONE BETWEEN BOTTOM CASE diff --git a/content/influxdb/cloud-dedicated/reference/sql/operators/other.md b/content/influxdb/cloud-dedicated/reference/sql/operators/other.md index 2b4af90f2..5fe800ec4 100644 --- a/content/influxdb/cloud-dedicated/reference/sql/operators/other.md +++ b/content/influxdb/cloud-dedicated/reference/sql/operators/other.md @@ -9,16 +9,18 @@ menu: parent: Operators weight: 305 list_code_example: | - | Operator | Meaning | Example | Result | - | :------: | :------------------- | :---------------------- | :------------ | - | `\|\|` | Concatenate strings | `'Hello' \|\| ' world'` | `Hello world` | + | Operator | Meaning | Example | Result | + | :------------: | :----------------------- | :-------------------------------------- | :------------ | + | `\|\|` | Concatenate strings | `'Hello' \|\| ' world'` | `Hello world` | + | `AT TIME ZONE` | Apply a time zone offset | _[View example](/influxdb/cloud-dedicated/reference/sql/operators/other/#at-time-zone)_ | | --- SQL supports miscellaneous operators that perform various operations. -| Operator | Meaning | | -| :------: | :------------------ | :------------------------------------------ | -| `\|\|` | Concatenate strings | [{{< icon "link" >}}](#concatenate-strings) | +| Operator | Meaning | | +| :------------: | :----------------------- | :------------------------------------------ | +| `\|\|` | Concatenate strings | [{{< icon "link" >}}](#concatenate-strings) | +| `AT TIME ZONE` | Apply a time zone offset | [{{< icon "link" >}}](#at-time-zone) | ## || {#concatenate-strings} @@ -40,3 +42,23 @@ SELECT 'Hello' || ' world' AS "Concatenated" {{% /flex-content %}} {{< /flex >}} + +## AT TIME ZONE + +The `AT TIME ZONE` operator applies the offset of the specified time zone to a +timestamp type and returns an updated UTC timestamp. Time zone offsets are +provided by the the operating system time zone database. + +{{% note %}} +Timestamp types in InfluxDB always represent a UTC time. The returned timestamp +is a UTC timestamp adjusted for the offset of the specified time zone. +{{% /note %}} + +```sql +SELECT + '2024-01-01 00:00:00'::TIMESTAMP AT TIME ZONE 'America/Los_Angeles' AS 'UTC with TZ offset' +``` + +| UTC with TZ offset | +| :----------------------- | +| 2024-01-01T08:00:00.000Z | diff --git a/content/influxdb/cloud-serverless/query-data/sql/basic-query.md b/content/influxdb/cloud-serverless/query-data/sql/basic-query.md index e4c1e8f64..8e65aa7e8 100644 --- a/content/influxdb/cloud-serverless/query-data/sql/basic-query.md +++ b/content/influxdb/cloud-serverless/query-data/sql/basic-query.md @@ -132,6 +132,33 @@ WHERE ``` {{% /influxdb/custom-timestamps %}} +{{% /expand %}} + +{{% expand "Query data using a time zone offset" %}} + +To query data using a time zone offset, use the +[`AT TIME ZONE` operator](/influxdb/cloud-serverless/reference/sql/operators/other/#at-time-zone) +to apply a time zone offset to timestamps in the `WHERE` clause. + +{{% note %}} +Timestamp types in InfluxDB always represent a UTC time. `AT TIME ZONE` returns +a UTC timestamp adjusted for the offset of the specified time zone. +Timestamps in the `time` column are not updated. +If you need to display the timestamps in your current timezone, this should be handled +client-side. +{{% /note %}} + +{{% influxdb/custom-timestamps %}} +```sql +SELECT + * +FROM + home +WHERE + time >= '2022-01-01 00:00:00'::TIMESTAMP AT TIME ZONE 'America/Los_Angeles' + AND time <= '2022-01-01 12:00:00'::TIMESTAMP AT TIME ZONE 'America/Los_Angeles' +``` +{{% /influxdb/custom-timestamps %}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/influxdb/cloud-serverless/reference/sql/_index.md b/content/influxdb/cloud-serverless/reference/sql/_index.md index ff686924e..92c3d0cf2 100644 --- a/content/influxdb/cloud-serverless/reference/sql/_index.md +++ b/content/influxdb/cloud-serverless/reference/sql/_index.md @@ -195,9 +195,10 @@ Bitwise operators perform bitwise operations on bit patterns or binary numerals. ### Other operators -| Operator | Meaning | Example | Result | -| :------: | :------------------- | :---------------------- | :------------ | -| `\|\|` | Concatenates strings | `'Hello' \|\| ' world'` | `Hello world` | +| Operator | Meaning | Example | Result | +| :------------: | :----------------------- | :--------------------------------------------------------------------------------------- | :------------ | +| `\|\|` | Concatenates strings | `'Hello' \|\| ' world'` | `Hello world` | +| `AT TIME ZONE` | Apply a time zone offset | _[View example](/influxdb/cloud-serverless/reference/sql/operators/other/#at-time-zone)_ | | ## Keywords @@ -209,6 +210,7 @@ ALL ANALYZE AS ASC +AT TIME ZONE BETWEEN BOTTOM CASE diff --git a/content/influxdb/cloud-serverless/reference/sql/operators/other.md b/content/influxdb/cloud-serverless/reference/sql/operators/other.md index bc2bb3725..cd4521194 100644 --- a/content/influxdb/cloud-serverless/reference/sql/operators/other.md +++ b/content/influxdb/cloud-serverless/reference/sql/operators/other.md @@ -9,9 +9,10 @@ menu: parent: Operators weight: 305 list_code_example: | - | Operator | Meaning | Example | Result | - | :------: | :------------------- | :---------------------- | :------------ | - | `\|\|` | Concatenate strings | `'Hello' \|\| ' world'` | `Hello world` | + | Operator | Meaning | Example | Result | + | :------------: | :----------------------- | :-------------------------------------- | :------------ | + | `\|\|` | Concatenate strings | `'Hello' \|\| ' world'` | `Hello world` | + | `AT TIME ZONE` | Apply a time zone offset | _[View example](/influxdb/cloud-serverless/reference/sql/operators/other/#at-time-zone)_ | | --- SQL supports miscellaneous operators that perform various operations. @@ -40,3 +41,23 @@ SELECT 'Hello' || ' world' AS "Concatenated" {{% /flex-content %}} {{< /flex >}} + +## AT TIME ZONE + +The `AT TIME ZONE` operator applies the offset of the specified time zone to a +timestamp type and returns an updated UTC timestamp. Time zone offsets are +provided by the the operating system time zone database. + +{{% note %}} +Timestamp types in InfluxDB always represent a UTC time. The returned timestamp +is a UTC timestamp adjusted for the offset of the specified time zone. +{{% /note %}} + +```sql +SELECT + '2024-01-01 00:00:00'::TIMESTAMP AT TIME ZONE 'America/Los_Angeles' AS 'UTC with TZ offset' +``` + +| UTC with TZ offset | +| :----------------------- | +| 2024-01-01T08:00:00.000Z | diff --git a/content/influxdb/clustered/query-data/sql/basic-query.md b/content/influxdb/clustered/query-data/sql/basic-query.md index 7946aa828..434ff1001 100644 --- a/content/influxdb/clustered/query-data/sql/basic-query.md +++ b/content/influxdb/clustered/query-data/sql/basic-query.md @@ -132,6 +132,33 @@ WHERE ``` {{% /influxdb/custom-timestamps %}} +{{% /expand %}} + +{{% expand "Query data using a time zone offset" %}} + +To query data using a time zone offset, use the +[`AT TIME ZONE` operator](/influxdb/clustered/reference/sql/operators/other/#at-time-zone) +to apply a time zone offset to timestamps in the `WHERE` clause. + +{{% note %}} +Timestamp types in InfluxDB always represent a UTC time. `AT TIME ZONE` returns +a UTC timestamp adjusted for the offset of the specified time zone. +Timestamps in the `time` column are not updated. +If you need to display the timestamps in your current timezone, this should be handled +client-side. +{{% /note %}} + +{{% influxdb/custom-timestamps %}} +```sql +SELECT + * +FROM + home +WHERE + time >= '2022-01-01 00:00:00'::TIMESTAMP AT TIME ZONE 'America/Los_Angeles' + AND time <= '2022-01-01 12:00:00'::TIMESTAMP AT TIME ZONE 'America/Los_Angeles' +``` +{{% /influxdb/custom-timestamps %}} {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/influxdb/clustered/reference/sql/_index.md b/content/influxdb/clustered/reference/sql/_index.md index bb214e16b..ed3dcd629 100644 --- a/content/influxdb/clustered/reference/sql/_index.md +++ b/content/influxdb/clustered/reference/sql/_index.md @@ -195,9 +195,10 @@ Bitwise operators perform bitwise operations on bit patterns or binary numerals. ### Other operators -| Operator | Meaning | Example | Result | -| :------: | :------------------- | :---------------------- | :------------ | -| `\|\|` | Concatenates strings | `'Hello' \|\| ' world'` | `Hello world` | +| Operator | Meaning | Example | Result | +| :------------: | :----------------------- | :-------------------------------------------------------------------------------- | :------------ | +| `\|\|` | Concatenates strings | `'Hello' \|\| ' world'` | `Hello world` | +| `AT TIME ZONE` | Apply a time zone offset | _[View example](/influxdb/clustered/reference/sql/operators/other/#at-time-zone)_ | | ## Keywords @@ -209,6 +210,7 @@ ALL ANALYZE AS ASC +AT TIME ZONE BETWEEN BOTTOM CASE diff --git a/content/influxdb/clustered/reference/sql/operators/other.md b/content/influxdb/clustered/reference/sql/operators/other.md index deccebe0e..837f67cf1 100644 --- a/content/influxdb/clustered/reference/sql/operators/other.md +++ b/content/influxdb/clustered/reference/sql/operators/other.md @@ -9,9 +9,10 @@ menu: parent: Operators weight: 305 list_code_example: | - | Operator | Meaning | Example | Result | - | :------: | :------------------- | :---------------------- | :------------ | - | `\|\|` | Concatenate strings | `'Hello' \|\| ' world'` | `Hello world` | + | Operator | Meaning | Example | Result | + | :------------: | :----------------------- | :-------------------------------------- | :------------ | + | `\|\|` | Concatenate strings | `'Hello' \|\| ' world'` | `Hello world` | + | `AT TIME ZONE` | Apply a time zone offset | _[View example](/influxdb/clustered/reference/sql/operators/other/#at-time-zone)_ | | --- SQL supports miscellaneous operators that perform various operations. @@ -40,3 +41,23 @@ SELECT 'Hello' || ' world' AS "Concatenated" {{% /flex-content %}} {{< /flex >}} + +## AT TIME ZONE + +The `AT TIME ZONE` operator applies the offset of the specified time zone to a +timestamp type and returns an updated UTC timestamp. Time zone offsets are +provided by the the operating system time zone database. + +{{% note %}} +Timestamp types in InfluxDB always represent a UTC time. The returned timestamp +is a UTC timestamp adjusted for the offset of the specified time zone. +{{% /note %}} + +```sql +SELECT + '2024-01-01 00:00:00'::TIMESTAMP AT TIME ZONE 'America/Los_Angeles' AS 'UTC with TZ offset' +``` + +| UTC with TZ offset | +| :----------------------- | +| 2024-01-01T08:00:00.000Z |