BigQuery
Date & Time35 fungsi

Fungsi Date & Time BigQuery

Fungsi untuk bekerja dengan tanggal dan waktu. Temukan semua 35 fungsi date & time di BigQuery lengkap dengan syntax, contoh, dan penjelasan bahasa Indonesia.

35 fungsi date & time di BigQuery

← Semua fungsi BigQuery

CURRENT_DATE

Date & Time

Returns the current date based on the specified timezone or the default timezone.

Tipe hasil: DATE

CURRENT_DATETIME

Date & Time

Returns the current datetime (date and time without timezone information) based on the specified timezone.

Tipe hasil: DATETIME

CURRENT_TIME

Date & Time

Returns the current time (without a date) based on the specified timezone.

Tipe hasil: TIME

CURRENT_TIMESTAMP

Date & Time

Returns the current timestamp in UTC. This is the most common way to get the current date and time in BigQuery.

Tipe hasil: TIMESTAMP

DATE

Date & Time

Creates a DATE value from individual components, or extracts a DATE from a timestamp or datetime expression.

Tipe hasil: DATE

DATETIME

Date & Time

Creates a DATETIME value from components, combines a DATE and TIME, or converts from a TIMESTAMP.

Tipe hasil: DATETIME

DATETIME_ADD

Date & Time

Adds a time interval to a DATETIME value. Supports all units from MICROSECOND to YEAR.

Tipe hasil: DATETIME

DATETIME_DIFF

Date & Time

Calculates the difference between two DATETIME values in the specified unit.

Tipe hasil: INT64

DATETIME_SUB

Date & Time

Subtracts a time interval from a DATETIME value. The inverse of DATETIME_ADD.

Tipe hasil: DATETIME

DATETIME_TRUNC

Date & Time

Truncates a DATETIME value to the specified granularity. Supports all date parts from MICROSECOND through YEAR.

Tipe hasil: DATETIME

DATE_ADD

Date & Time

Adds a specified time interval to a DATE. Returns a new DATE.

Tipe hasil: DATE

DATE_DIFF

Date & Time

Calculates the difference between two DATE values in the specified unit. Returns an integer value.

Tipe hasil: INT64

DATE_SUB

Date & Time

Subtracts a specified time interval from a DATE. Returns a new DATE.

Tipe hasil: DATE

DATE_TRUNC

Date & Time

Truncates a DATE to the specified granularity (DAY, WEEK, MONTH, QUARTER, YEAR).

Tipe hasil: DATE

EXTRACT

Date & Time

Extracts a specific component from a DATE, TIME, DATETIME, or TIMESTAMP value. Returns an integer.

Tipe hasil: INT64

FORMAT_DATE

Date & Time

Formats a DATE value into a string based on the specified format. Uses standard format elements.

Tipe hasil: STRING

FORMAT_DATETIME

Date & Time

Formats a DATETIME value into a string. Combines format elements for both date and time.

Tipe hasil: STRING

FORMAT_TIME

Date & Time

Formats a TIME value into a string based on the specified format.

Tipe hasil: STRING

FORMAT_TIMESTAMP

Date & Time

Formats a TIMESTAMP value into a string. Supports timezone for accurate display.

Tipe hasil: STRING

LAST_DAY

Date & Time

Returns the last day of the specified period (month, quarter, or year).

Tipe hasil: DATE

MAKE_DATE

Date & Time

Membuat DATE dari komponen year, month, dan day.

Tipe hasil: DATE

PARSE_DATE

Date & Time

Parses a string into a DATE based on the specified format. The inverse of FORMAT_DATE.

Tipe hasil: DATE

PARSE_DATETIME

Date & Time

Converts a string into a DATETIME type based on the specified format.

Tipe hasil: DATETIME

PARSE_TIME

Date & Time

Converts a time string into a TIME type based on the specified format.

Tipe hasil: TIME

PARSE_TIMESTAMP

Date & Time

Converts a string to a TIMESTAMP type with timezone support.

Tipe hasil: TIMESTAMP

TIME

Date & Time

Creates a TIME value from components, or extracts the TIME portion from a timestamp or datetime.

Tipe hasil: TIME

TIMESTAMP

Date & Time

Creates a TIMESTAMP value from a string, DATE, or DATETIME. TIMESTAMP values are always stored in UTC.

Tipe hasil: TIMESTAMP

TIMESTAMP_ADD

Date & Time

Adds a time interval to a TIMESTAMP value. The result remains in UTC.

Tipe hasil: TIMESTAMP

TIMESTAMP_DIFF

Date & Time

Calculates the difference between two TIMESTAMP values in the specified unit. Most accurate for measuring absolute durations.

Tipe hasil: INT64

TIMESTAMP_SUB

Date & Time

Subtracts a time interval from a TIMESTAMP value. The inverse of TIMESTAMP_ADD.

Tipe hasil: TIMESTAMP

TIMESTAMP_TRUNC

Date & Time

Truncates a TIMESTAMP to the specified granularity. Supports timezone for accurate local-time results.

Tipe hasil: TIMESTAMP

TIME_ADD

Date & Time

Adds a time interval to a TIME value. Useful for work-hour calculations and scheduling.

Tipe hasil: TIME

TIME_DIFF

Date & Time

Calculates the difference between two TIME values in the specified unit.

Tipe hasil: INT64

TIME_SUB

Date & Time

Subtracts a time interval from a TIME value. The inverse of TIME_ADD.

Tipe hasil: TIME

TIME_TRUNC

Date & Time

Truncates a TIME value to the specified granularity (MICROSECOND, MILLISECOND, SECOND, MINUTE, HOUR).

Tipe hasil: TIME