SQL time zone support (#5441)
* add infomrmation about sql timezone support * Apply suggestions from code review Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com> * fixed typos --------- Co-authored-by: Jason Stirnaman <stirnamanj@gmail.com>token-wildcard
parent
057218aabe
commit
95cab5bf30
|
|
@ -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 >}}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 |
|
||||
|
|
|
|||
|
|
@ -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 >}}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 |
|
||||
|
|
|
|||
|
|
@ -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 >}}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 |
|
||||
|
|
|
|||
Loading…
Reference in New Issue