תיאור מפורט של פונקציות חותמת זמן

פונקציות של חותמות זמן

שם תיאור
CURRENT_TIMESTAMP יוצר TIMESTAMP שתואם לזמן הבקשה.
TIMESTAMP_TRUNC הפונקציה מקצרת TIMESTAMP לרמת פירוט נתונה.
UNIX_MICROS_TO_TIMESTAMP הפונקציה ממירה את מספר המיקרו-שניות שחלפו מאז 1970-01-01 00:00:00 UTC ל-TIMESTAMP
UNIX_MILLIS_TO_TIMESTAMP הפונקציה ממירה את מספר אלפיות השנייה מאז 1970-01-01 00:00:00 UTC ל-TIMESTAMP
UNIX_SECONDS_TO_TIMESTAMP הפונקציה ממירה את מספר השניות שחלפו מאז 1970-01-01 00:00:00 UTC ל-TIMESTAMP
TIMESTAMP_ADD הוספת מרווח זמן לTIMESTAMP
TIMESTAMP_SUB הפונקציה מחסירה מרווח זמן מ-TIMESTAMP
TIMESTAMP_TO_UNIX_MICROS הפונקציה ממירה TIMESTAMP למספר המיקרו-שניות שחלפו מאז 1970-01-01 00:00:00 UTC
TIMESTAMP_TO_UNIX_MILLIS הפונקציה ממירה TIMESTAMP למספר אלפיות השנייה שחלפו מאז 1970-01-01 00:00:00 UTC
TIMESTAMP_TO_UNIX_SECONDS הפונקציה ממירה את TIMESTAMP למספר השניות שחלפו מאז 1970-01-01 00:00:00 UTC
TIMESTAMP_DIFF הפונקציה מחזירה את המספר השלם של מרווחי הזמן שצוינו ב-unit בין שני ערכי TIMESTAMP.
TIMESTAMP_EXTRACT מחלצת part ספציפי (למשל: שנה, חודש, יום) מתוך TIMESTAMP.

CURRENT_TIMESTAMP

תחביר:

current_timestamp() -> TIMESTAMP

תיאור:

הפונקציה מקבלת את חותמת הזמן בתחילת זמן הבקשה input (מפורשת כמספר המיקרו-שניות מאז 1970-01-01 00:00:00 UTC).

הערך הזה יציב בתוך שאילתה, ותמיד יחזיר את אותו ערך אם קוראים לו כמה פעמים.

TIMESTAMP_TRUNC

תחביר:

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

תיאור:

הפונקציה מקצרת חותמת זמן לרמת פירוט נתונה.

הארגומנט granularity חייב להיות מחרוזת ואחד מהערכים הבאים:

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

אם הארגומנט timezone צוין, החיתוך יתבסס על גבולות לוח השנה של אזור הזמן שצוין (לדוגמה, חיתוך יום יחתוך לחצות באזור הזמן שצוין). החיתוך יתחשב בשעון קיץ.

אם לא מציינים את timezone, החיתוך יתבסס על גבולות לוח השנה של UTC.

הארגומנט timezone צריך להיות ייצוג מחרוזת של אזור זמן ממסד הנתונים של tz, לדוגמה America/New_York. אפשר גם להשתמש בהזמן שחלף מותאם אישית על ידי ציון היסט מ-GMT.

לדוגמה:

timestamp granularity timezone timestamp_trunc(timestamp, granularity, timezone)
2000-01-01 10:20:30:123456 UTC "שנייה" לא צוין ‫2001-01-01 10:20:30 לפי שעון UTC
1997-05-31 04:30:30 UTC "day" לא צוין ‫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) לא צוין 2001-03-16 00:00:00 UTC
‫23 במרץ 2001, 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

תחביר:

unix_micros_to_timestamp(input: INT64) -> TIMESTAMP

תיאור:

הפונקציה ממירה את input (שמפורש כמספר המיקרו-שניות מאז 1970-01-01 00:00:00 UTC) ל-TIMESTAMP. הפונקציה מחזירה error אם אי אפשר להמיר את input ל-TIMESTAMP תקין.

לדוגמה:

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();

אתר

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();
המשך
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.UnixMicrosToTimestamp(firestore.FieldOf("createdAtMicros")).As("createdAtString"),
	)).
	Execute(ctx)

UNIX_MILLIS_TO_TIMESTAMP

תחביר:

unix_millis_to_timestamp(input: INT64) -> TIMESTAMP

תיאור:

הפונקציה ממירה את input (שמפורש כמספר אלפיות השנייה מאז 1970-01-01 00:00:00 UTC) ל-TIMESTAMP. הפונקציה מחזירה error אם אי אפשר להמיר את input ל-TIMESTAMP תקין.

לדוגמה:

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();

אתר

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();
המשך
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.UnixMillisToTimestamp(firestore.FieldOf("createdAtMillis")).As("createdAtString"),
	)).
	Execute(ctx)

UNIX_SECONDS_TO_TIMESTAMP

תחביר:

unix_seconds_to_timestamp(input: INT64) -> TIMESTAMP

תיאור:

הפונקציה ממירה את input (שמפורש כמספר השניות שחלפו מאז 1970-01-01 00:00:00 UTC) ל-TIMESTAMP. הפונקציה מחזירה error אם אי אפשר להמיר את input ל-TIMESTAMP תקין.

לדוגמה:

input unix_seconds_to_timestamp(input)
0L 1970-01-01 00:00:00 UTC
60L 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();

אתר

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();
המשך
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.UnixSecondsToTimestamp(firestore.FieldOf("createdAtSeconds")).As("createdAtString"),
	)).
	Execute(ctx)

TIMESTAMP_ADD

תחביר:

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

תיאור:

הוספת amount של unit מ-timestamp. הארגומנט amount יכול להיות שלילי, ובמקרה כזה הוא שווה ערך ל-TIMESTAMP_SUB.

הארגומנט unit חייב להיות מחרוזת ואחד מהערכים הבאים:

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

אם חותמת הזמן שמתקבלת לא נמצאת בטווח של TIMESTAMP, תופיע שגיאה.

לדוגמה:

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 "שעה" -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();

אתר

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();
המשך
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.TimestampAdd(firestore.FieldOf("createdAt"), "day", 3653).As("expiresAt"),
	)).
	Execute(ctx)

TIMESTAMP_SUB

תחביר:

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

תיאור:

הפונקציה מחסירה amount של unit מ-timestamp. הארגומנט amount יכול להיות שלילי, ובמקרה כזה הוא שווה ערך ל-TIMESTAMP_ADD.

הארגומנט unit חייב להיות מחרוזת ואחד מהערכים הבאים:

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

אם חותמת הזמן שמתקבלת לא נמצאת בטווח של TIMESTAMP, תופיע שגיאה.

לדוגמה:

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 "שעה" -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();

אתר

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();
המשך
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.TimestampSubtract(firestore.FieldOf("expiresAt"), "day", 14).As("sendWarningTimestamp"),
	)).
	Execute(ctx)

TIMESTAMP_TO_UNIX_MICROS

תחביר:

timestamp_to_unix_micros(input: TIMESTAMP | BSON_TIMESTAMP) -> INT64

תיאור:

הפונקציה ממירה את input למספר המיקרו-שניות שחלפו מאז 1970-01-01 00:00:00 UTC. הפונקציה מקצרת רמות דיוק גבוהות יותר על ידי עיגול כלפי מטה לתחילת המיקרו-שנייה.

לדוגמה:

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();

אתר

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();
המשך
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.TimestampToUnixMicros(firestore.FieldOf("dateString")).As("unixMicros"),
	)).
	Execute(ctx)

TIMESTAMP_TO_UNIX_MILLIS

תחביר:

timestamp_to_unix_millis(input: TIMESTAMP | BSON_TIMESTAMP) -> INT64

תיאור:

הפונקציה ממירה את input למספר אלפיות השנייה שחלפו מאז 1970-01-01 00:00:00 UTC. הפונקציה מקצרת רמות דיוק גבוהות יותר על ידי עיגול כלפי מטה לתחילת האלפית השנייה.

לדוגמה:

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();

אתר

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();
המשך
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.TimestampToUnixMillis(firestore.FieldOf("dateString")).As("unixMillis"),
	)).
	Execute(ctx)

TIMESTAMP_TO_UNIX_SECONDS

תחביר:

timestamp_to_unix_seconds(input: TIMESTAMP | BSON_TIMESTAMP) -> INT64

תיאור:

הפונקציה ממירה את input למספר השניות שחלפו מאז 1970-01-01 00:00:00 UTC. הפונקציה מקצרת רמות דיוק גבוהות יותר על ידי עיגול כלפי מטה לתחילת השנייה.

לדוגמה:

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

אתר

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();
המשך
snapshot := client.Pipeline().
	Collection("documents").
	Select(firestore.Fields(
		firestore.TimestampToUnixSeconds(firestore.FieldOf("dateString")).As("unixSeconds"),
	)).
	Execute(ctx)

TIMESTAMP_DIFF

תחביר:

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

תיאור:

הפונקציה מחזירה את המספר השלם של מרווחי הזמן שצוינו ב-unit בין שני ערכי TIMESTAMP.

  • הפונקציה מחזירה ערך שלילי אם end לפני start.
  • הפונקציה מקצרת כל יחידת שבר. לדוגמה, הפונקציה timestamp_diff("2021-01-01 00:00:01", "2021-01-01 00:00:00", "minute") מחזירה את הערך 0.

הארגומנט unit חייב להיות מחרוזת ואחד מהערכים הבאים:

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

לדוגמה:

end start unit timestamp_diff(end, start, unit)
‫2026-07-04 00:01:00 UTC 2026-07-04 00:00:00 UTC "שנייה" 60L
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

תחביר:

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

תיאור:

מחלצת part ספציפי (למשל: שנה, חודש, יום) מתוך timestamp.

הארגומנט part חייב להיות מחרוזת ואחד מהערכים הבאים:

  • microsecond
  • millisecond
  • second
  • minute
  • hour
  • day
  • ‫dayofweek: מחזירה ערך בין 1 (יום ראשון) ל-7 (יום שבת).
  • dayofyear
  • ‫week: מחזירה את מספר השבוע בשנה, החל מ-1 ליום ראשון הראשון בשנה.
  • ‫week([weekday]): הפונקציה מחזירה את מספר השבוע בשנה, החל מהיום weekday שצוין.
  • month
  • quarter
  • year
  • ‫isoweek: מחזירה את מספר השבוע לפי תקן ISO 8601.
  • ‫isoyear: מחזירה את השנה לפי מספור השבועות של ISO 8601.

אם הארגומנט timezone צוין, החילוץ יתבסס על היומן של אזור הזמן שצוין. החילוץ יתחשב בשעון קיץ.

אם לא צוין timezone, החילוץ יתבסס על UTC.

הארגומנט timezone צריך להיות ייצוג מחרוזת של אזור זמן ממסד הנתונים של אזורי הזמן, לדוגמה America/New_York. אפשר גם להשתמש בהזמן שחלף בהתאמה אישית על ידי ציון היסט מ-GMT.

לדוגמה:

timestamp part timezone timestamp_extract(timestamp, part, timezone)
2025-02-20 10:20:30 UTC "year" לא צוין 2025
2025-02-20 10:20:30 UTC "day" לא צוין 20
‫2025-12-31 23:59:59 לפי שעון UTC "year" "Asia/Tokyo" 2026

המאמרים הבאים