Referenz zu Zeitstempelfunktionen

Zeitstempelfunktionen

Name Beschreibung
CURRENT_TIMESTAMP Generiert einen TIMESTAMP, der der Anfragezeit entspricht.
TIMESTAMP_TRUNC Kürzt einen TIMESTAMP-Wert auf eine bestimmte Granularität.
UNIX_MICROS_TO_TIMESTAMP Wandelt die Anzahl der Mikrosekunden seit 1970-01-01 00:00:00 UTC in einen TIMESTAMP um.
UNIX_MILLIS_TO_TIMESTAMP Wandelt die Anzahl der Millisekunden seit 1970-01-01 00:00:00 UTC in einen TIMESTAMP um
UNIX_SECONDS_TO_TIMESTAMP Konvertiert die Anzahl der Sekunden seit 1970-01-01 00:00:00 UTC in einen TIMESTAMP.
TIMESTAMP_ADD Fügt einem TIMESTAMP ein Zeitintervall hinzu
TIMESTAMP_SUB Subtrahiert ein Zeitintervall von einem TIMESTAMP
TIMESTAMP_TO_UNIX_MICROS Wandelt einen TIMESTAMP-Wert in die Anzahl der Mikrosekunden seit 1970-01-01 00:00:00 UTC um.
TIMESTAMP_TO_UNIX_MILLIS Wandelt einen TIMESTAMP in die Anzahl der Millisekunden seit 1970-01-01 00:00:00 UTC um
TIMESTAMP_TO_UNIX_SECONDS Wandelt einen TIMESTAMP in die Anzahl der Sekunden seit 1970-01-01 00:00:00 UTC um
TIMESTAMP_DIFF Gibt die ganze Zahl der angegebenen unit-Intervalle zwischen zwei TIMESTAMP-Werten zurück.
TIMESTAMP_EXTRACT Extrahiert einen bestimmten part (z.B. Jahr, Monat, Tag) aus einem TIMESTAMP.

CURRENT_TIMESTAMP

Syntax:

current_timestamp() -> TIMESTAMP

Beschreibung:

Ruft den Zeitstempel am Anfang der Anfragezeit input ab (interpretiert als Anzahl der Mikrosekunden seit 1970-01-01 00:00:00 UTC).

Dieser Wert ist innerhalb einer Abfrage stabil und wird immer in denselben Wert aufgelöst, wenn er mehrmals aufgerufen wird.

TIMESTAMP_TRUNC

Syntax:

timestamp_trunc(timestamp: TIMESTAMP | BSON_TIMESTAMP, granularity: STRING[, timezone: STRING]) -> TIMESTAMP

Beschreibung:

Kürzt einen Zeitstempel auf eine bestimmte Granularität.

Das Argument granularity muss ein String und einer der folgenden Werte sein:

  • microsecond
  • millisecond
  • second
  • minute
  • hour
  • day
  • week
  • week([weekday])
  • month
  • quarter
  • year
  • isoyear

Wenn das Argument timezone angegeben ist, basiert die Kürzung auf den Kalendergrenzen der angegebenen Zeitzone (z.B. wird die Kürzung auf den Tag in der angegebenen Zeitzone auf Mitternacht gekürzt). Bei der Kürzung wird die Sommerzeit berücksichtigt.

Wenn timezone nicht angegeben ist, basiert die Kürzung auf den Kalendergrenzen von UTC.

Das Argument timezone sollte eine Stringdarstellung einer Zeitzone aus der tz-Datenbank sein, z. B. America/New_York. Sie können auch einen benutzerdefinierten Zeitversatz verwenden, indem Sie einen Versatz von GMT angeben.

Beispiele:

timestamp granularity timezone timestamp_trunc(timestamp, granularity, timezone)
2000-01-01 10:20:30:123456 UTC „second“ Nicht bereitgestellt 2001-01-01 10:20:30 UTC
1997-05-31 04:30:30 UTC "day" Nicht bereitgestellt 1997-05-31 00:00:00 UTC
1997-05-31 04:30:30 UTC "day" "America/Los_Angeles" 1997-05-30 07:00:00 UTC
2001-03-16 04:00:00 UTC "week(friday) Nicht bereitgestellt 2001-03-16 00:00:00 UTC
2001-03-23 04:00:00 UTC "week(friday) "America/Los_Angeles" 2001-03-23 17:00:00 UTC
2026-01-24 20:00:00 UTC "month" "GMT+06:32:43" 2026-01-01T06:32:43 UTC

UNIX_MICROS_TO_TIMESTAMP

Syntax:

unix_micros_to_timestamp(input: INT64) -> TIMESTAMP

Beschreibung:

Konvertiert input (interpretiert als die Anzahl der Mikrosekunden seit 1970-01-01 00:00:00 UTC) in einen TIMESTAMP. Löst einen error aus, wenn input nicht in einen gültigen TIMESTAMP konvertiert werden kann.

Beispiele:

input unix_micros_to_timestamp(input)
0L 1970-01-01 00:00:00 UTC
400123456L 1970-01-01 00:06:40.123456 UTC
-1000000L 1969-12-31 23:59:59 UTC
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("createdAtMicros").unixMicrosToTimestamp().as("createdAtString")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("createdAtMicros").unixMicrosToTimestamp().as("createdAtString")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("createdAtMicros").unixMicrosToTimestamp().as("createdAtString")
  ])
  .execute()
Kotlin
Android
val result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAtMicros").unixMicrosToTimestamp().alias("createdAtString")
    )
    .execute()
Java
Android
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAtMicros").unixMicrosToTimestamp().alias("createdAtString")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(
        Field.of("createdAtMicros")
        .unix_micros_to_timestamp()
        .as_("createdAtString")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(unixMicrosToTimestamp(field("createdAtMicros")).as("createdAtString"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.UnixMicrosToTimestamp(firestore.FieldOf("createdAtMicros")).As("createdAtString"),
	)).
	Execute(ctx)

UNIX_MILLIS_TO_TIMESTAMP

Syntax:

unix_millis_to_timestamp(input: INT64) -> TIMESTAMP

Beschreibung:

Konvertiert input (interpretiert als Anzahl der Millisekunden seit 1970-01-01 00:00:00 UTC) in einen TIMESTAMP. Löst einen error aus, wenn input nicht in einen gültigen TIMESTAMP konvertiert werden kann.

Beispiele:

input unix_millis_to_timestamp(input)
0L 1970-01-01 00:00:00 UTC
4000123L 1970-01-01 01:06:40.123 UTC
-1000000L 1969-12-31 23:43:20 UTC
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("createdAtMillis").unixMillisToTimestamp().as("createdAtString")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("createdAtMillis").unixMillisToTimestamp().as("createdAtString")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("createdAtMillis").unixMillisToTimestamp().as("createdAtString")
  ])
  .execute()
Kotlin
Android
val result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAtMillis").unixMillisToTimestamp().alias("createdAtString")
    )
    .execute()
Java
Android
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAtMillis").unixMillisToTimestamp().alias("createdAtString")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(
        Field.of("createdAtMillis")
        .unix_millis_to_timestamp()
        .as_("createdAtString")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(unixMillisToTimestamp(field("createdAtMillis")).as("createdAtString"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.UnixMillisToTimestamp(firestore.FieldOf("createdAtMillis")).As("createdAtString"),
	)).
	Execute(ctx)

UNIX_SECONDS_TO_TIMESTAMP

Syntax:

unix_seconds_to_timestamp(input: INT64) -> TIMESTAMP

Beschreibung:

Konvertiert input (interpretiert als Anzahl der Sekunden seit 1970-01-01 00:00:00 UTC) in einen TIMESTAMP. Löst einen error aus, wenn input nicht in einen gültigen TIMESTAMP konvertiert werden kann.

Beispiele:

input unix_seconds_to_timestamp(input)
0L 1970-01-01 00:00:00 UTC
60 l 1970-01-01 00:01:00 UTC
-300L 1969-12-31 23:55:00 UTC
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("createdAtSeconds").unixSecondsToTimestamp().as("createdAtString")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("createdAtSeconds").unixSecondsToTimestamp().as("createdAtString")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("createdAtSeconds").unixSecondsToTimestamp().as("createdAtString")
  ])
  .execute()
Kotlin
Android
val result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAtSeconds").unixSecondsToTimestamp().alias("createdAtString")
    )
    .execute()
Java
Android
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAtSeconds").unixSecondsToTimestamp().alias("createdAtString")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(
        Field.of("createdAtSeconds")
        .unix_seconds_to_timestamp()
        .as_("createdAtString")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(unixSecondsToTimestamp(field("createdAtSeconds")).as("createdAtString"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.UnixSecondsToTimestamp(firestore.FieldOf("createdAtSeconds")).As("createdAtString"),
	)).
	Execute(ctx)

TIMESTAMP_ADD

Syntax:

timestamp_add(timestamp: TIMESTAMP | BSON_TIMESTAMP, unit: STRING, amount: INT64) -> TIMESTAMP

Beschreibung:

Fügt ein amount von unit aus timestamp hinzu. Das Argument amount kann negativ sein. In diesem Fall entspricht es TIMESTAMP_SUB.

Das Argument unit muss ein String und einer der folgenden Werte sein:

  • microsecond
  • millisecond
  • second
  • minute
  • hour
  • day

Löst einen Fehler aus, wenn der resultierende Zeitstempel nicht in den TIMESTAMP-Bereich passt.

Beispiele:

timestamp unit amount timestamp_add(timestamp, unit, amount)
2025-02-20 00:00:00 UTC "minute" 2L 2025-02-20 00:02:00 UTC
2025-02-20 00:00:00 UTC "hour" -4L 2025-02-19 20:00:00 UTC
2025-02-20 00:00:00 UTC "day" 5L 2025-02-25 00:00:00 UTC
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("createdAt").timestampAdd("day", 3653).as("expiresAt")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("createdAt").timestampAdd("day", 3653).as("expiresAt")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("createdAt").timestampAdd(3653, .day).as("expiresAt")
  ])
  .execute()
Kotlin
Android
val result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAt")
          .timestampAdd("day", 3653)
          .alias("expiresAt")
    )
    .execute()
Java
Android
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("createdAt").timestampAdd("day", 3653).alias("expiresAt")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(Field.of("createdAt").timestamp_add("day", 3653).as_("expiresAt"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(timestampAdd(field("createdAt"), "day", 3653).as("expiresAt"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.TimestampAdd(firestore.FieldOf("createdAt"), "day", 3653).As("expiresAt"),
	)).
	Execute(ctx)

TIMESTAMP_SUB

Syntax:

timestamp_sub(timestamp: TIMESTAMP | BSON_TIMESTAMP, unit: STRING, amount: INT64) -> TIMESTAMP

Beschreibung:

Subtrahiert einen amount von unit von timestamp. Das Argument amount kann negativ sein. In diesem Fall entspricht es TIMESTAMP_ADD.

Das Argument unit muss ein String und einer der folgenden Werte sein:

  • microsecond
  • millisecond
  • second
  • minute
  • hour
  • day

Löst einen Fehler aus, wenn der resultierende Zeitstempel nicht in den TIMESTAMP-Bereich passt.

Beispiele:

timestamp unit amount timestamp_sub(timestamp, unit, amount)
2026-07-04 00:00:00 UTC "minute" 40L 2026-07-03 23:20:00 UTC
2026-07-04 00:00:00 UTC "hour" -24L 2026-07-05 00:00:00 UTC
2026-07-04 00:00:00 UTC "day" 3L 2026-07-01 00:00:00 UTC
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("expiresAt").timestampSubtract("day", 14).as("sendWarningTimestamp")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("expiresAt").timestampSubtract("day", 14).as("sendWarningTimestamp")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("expiresAt").timestampSubtract(14, .day).as("sendWarningTimestamp")
  ])
  .execute()
Kotlin
Android
val result = db.pipeline()
    .collection("documents")
    .select(
        field("expiresAt")
          .timestampSubtract("day", 14)
          .alias("sendWarningTimestamp")
    )
    .execute()
Java
Android
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("expiresAt").timestampSubtract("day", 14).alias("sendWarningTimestamp")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(
        Field.of("expiresAt")
        .timestamp_subtract("day", 14)
        .as_("sendWarningTimestamp")
    )
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(timestampSubtract(field("expiresAt"), "day", 14).as("sendWarningTimestamp"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.TimestampSubtract(firestore.FieldOf("expiresAt"), "day", 14).As("sendWarningTimestamp"),
	)).
	Execute(ctx)

TIMESTAMP_TO_UNIX_MICROS

Syntax:

timestamp_to_unix_micros(input: TIMESTAMP | BSON_TIMESTAMP) -> INT64

Beschreibung:

Wandelt input in die Anzahl der Mikrosekunden seit 1970-01-01 00:00:00 UTC um. Nachkommastellen werden durch das Abrunden auf den Anfang der Mikrosekunde abgeschnitten.

Beispiele:

input timestamp_to_unix_micros(input)
1970-01-01 00:00:00 UTC 0L
1970-01-01 00:06:40.123456 UTC 400123456L
1969-12-31 23:59:59 UTC -1000000L
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("dateString").timestampToUnixMicros().as("unixMicros")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("dateString").timestampToUnixMicros().as("unixMicros")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("dateString").timestampToUnixMicros().as("unixMicros")
  ])
  .execute()
Kotlin
Android
val result = db.pipeline()
    .collection("documents")
    .select(
        field("dateString").timestampToUnixMicros().alias("unixMicros")
    )
    .execute()
Java
Android
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("dateString").timestampToUnixMicros().alias("unixMicros")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(Field.of("dateString").timestamp_to_unix_micros().as_("unixMicros"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(timestampToUnixMicros(field("dateString")).as("unixMicros"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.TimestampToUnixMicros(firestore.FieldOf("dateString")).As("unixMicros"),
	)).
	Execute(ctx)

TIMESTAMP_TO_UNIX_MILLIS

Syntax:

timestamp_to_unix_millis(input: TIMESTAMP | BSON_TIMESTAMP) -> INT64

Beschreibung:

Wandelt input in die Anzahl der Millisekunden seit 1970-01-01 00:00:00 UTC um. Nachkommastellen werden durch das Abrunden auf den Anfang der Millisekunde abgeschnitten.

Beispiele:

input timestamp_to_unix_millis(input)
1970-01-01 00:00:00 UTC 0L
1970-01-01 01:06:40.123 UTC 4000123L
1969-12-31 23:43:20 -1000000L
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("dateString").timestampToUnixMillis().as("unixMillis")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("dateString").timestampToUnixMillis().as("unixMillis")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("dateString").timestampToUnixMillis().as("unixMillis")
  ])
  .execute()
Kotlin
Android
val result = db.pipeline()
    .collection("documents")
    .select(
        field("dateString").timestampToUnixMillis().alias("unixMillis")
    )
    .execute()
Java
Android
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("dateString").timestampToUnixMillis().alias("unixMillis")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(Field.of("dateString").timestamp_to_unix_millis().as_("unixMillis"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(timestampToUnixMillis(field("dateString")).as("unixMillis"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.TimestampToUnixMillis(firestore.FieldOf("dateString")).As("unixMillis"),
	)).
	Execute(ctx)

TIMESTAMP_TO_UNIX_SECONDS

Syntax:

timestamp_to_unix_seconds(input: TIMESTAMP | BSON_TIMESTAMP) -> INT64

Beschreibung:

Konvertiert input in die Anzahl der Sekunden seit 1970-01-01 00:00:00 UTC. Nachkommastellen werden durch das Abrunden auf den Anfang der Sekunde abgeschnitten.

Beispiele:

input timestamp_to_unix_seconds(input)
1970-01-01 00:00:00 UTC 0L
1970-01-01 00:01:00 UTC 60 l
1969-12-31 23:55:00 UTC -300L
Node.js
const result = await db.pipeline()
  .collection("documents")
  .select(
    field("dateString").timestampToUnixSeconds().as("unixSeconds")
  )
  .execute();

Web

const result = await execute(db.pipeline()
  .collection("documents")
  .select(
    field("dateString").timestampToUnixSeconds().as("unixSeconds")
  )
);
Swift
let result = try await db.pipeline()
  .collection("documents")
  .select([
    Field("dateString").timestampToUnixSeconds().as("unixSeconds")
  ])
  .execute()
Kotlin
Android
val result = db.pipeline()
    .collection("documents")
    .select(
        field("dateString").timestampToUnixSeconds().alias("unixSeconds")
    )
    .execute()
Java
Android
Task<Pipeline.Snapshot> result = db.pipeline()
    .collection("documents")
    .select(
        field("dateString").timestampToUnixSeconds().alias("unixSeconds")
    )
    .execute();
Python
from google.cloud.firestore_v1.pipeline_expressions import Field

result = (
    client.pipeline()
    .collection("documents")
    .select(Field.of("dateString").timestamp_to_unix_seconds().as_("unixSeconds"))
    .execute()
)
Java
Pipeline.Snapshot result =
    firestore
        .pipeline()
        .collection("documents")
        .select(timestampToUnixSeconds(field("dateString")).as("unixSeconds"))
        .execute()
        .get();
Go
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.TimestampToUnixSeconds(firestore.FieldOf("dateString")).As("unixSeconds"),
	)).
	Execute(ctx)

TIMESTAMP_DIFF

Syntax:

timestamp_diff(end: TIMESTAMP | BSON_TIMESTAMP, start: TIMESTAMP | BSON_TIMESTAMP, unit: STRING) -> INT64

Beschreibung:

Gibt die ganze Zahl der angegebenen unit-Intervalle zwischen zwei TIMESTAMP-Werten zurück.

  • Gibt einen negativen Wert zurück, wenn end vor start liegt.
  • Schneidet alle Bruchteile ab. Beispiel: timestamp_diff("2021-01-01 00:00:01", "2021-01-01 00:00:00", "minute") gibt 0 zurück.

Das Argument unit muss ein String und einer der folgenden Werte sein:

  • microsecond
  • millisecond
  • second
  • minute
  • hour
  • day

Beispiele:

end start unit timestamp_diff(end, start, unit)
2026-07-04 00:01:00 UTC 2026-07-04 00:00:00 UTC „second“ 60 l
2026-07-04 00:00:00 UTC 2026-07-05 00:00:00 UTC "day" -1L
2026-07-04 00:00:59 UTC 2026-07-04 00:00:00 UTC "minute" 0L

TIMESTAMP_EXTRACT

Syntax:

timestamp_extract(timestamp: TIMESTAMP | BSON_TIMESTAMP, part: STRING[, timezone: STRING]) -> INT64

Beschreibung:

Extrahiert einen bestimmten part (z.B. Jahr, Monat, Tag) aus timestamp.

Das Argument part muss ein String und einer der folgenden Werte sein:

  • microsecond
  • millisecond
  • second
  • minute
  • hour
  • day
  • dayofweek: Gibt einen Wert zwischen 1 (Sonntag) und 7 (Samstag) zurück.
  • dayofyear
  • week: Gibt die Wochennummer des Jahres zurück, beginnend mit 1 für den ersten Sonntag des Jahres.
  • week([weekday]): Gibt die Kalenderwoche des Jahres zurück, beginnend mit dem angegebenen weekday.
  • month
  • quarter
  • year
  • isoweek: Gibt die ISO 8601-Wochennummer zurück.
  • isoyear: Gibt das Jahr mit ISO 8601-Wochennummerierung zurück.

Wenn das Argument timezone angegeben ist, basiert die Extraktion auf dem Kalender der angegebenen Zeitzone. Bei der Extraktion wird die Sommerzeit berücksichtigt.

Wenn timezone nicht angegeben ist, basiert die Extraktion auf UTC.

Das Argument timezone sollte eine Stringdarstellung einer Zeitzone aus der Zeitzonendatenbank sein, z. B. America/New_York. Sie können auch einen benutzerdefinierten zeitlichen Versatz verwenden, indem Sie einen Versatz von GMT angeben.

Beispiele:

timestamp part timezone timestamp_extract(timestamp, part, timezone)
2025-02-20 10:20:30 UTC "year" Nicht bereitgestellt 2025
2025-02-20 10:20:30 UTC "day" Nicht bereitgestellt 20
2025-12-31 23:59:59 UTC "year" "Asia/Tokyo" 2026

Nächste Schritte