# BigQuery POW / POWER: Syntax, Examples and Gotchas | Masthead

POW(x, y) raises x to the power y, and POWER is a synonym: POW(2, 10) returns 1024.0. INT64 inputs return FLOAT64, NUMERIC inputs stay exact. Use it for growth rates, squares and unit conversions such as bytes / POW(1024, 4). The ^ operator is bitwise XOR, not a power.

> For the index of this section of the site, see [llms.txt](https://mastheadata.com/llms.txt)

BigQuery · Math function

# BigQuery POW / POWER

POW(x, y) raises x to the power y, and POWER is a synonym: POW(2, 10) returns 1024.0. INT64 inputs return FLOAT64, NUMERIC inputs stay exact. Use it for growth rates, squares and unit conversions such as bytes / POW(1024, 4). The ^ operator is bitwise XOR, not a power.

GoogleSQL for BigQuery · Checked against the [official reference](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/mathematical_functions#pow) in November 2026

POW and POWER are the same function. With INT64 arguments the result is FLOAT64 (`POW(2, 3)` is 8.0); with NUMERIC or BIGNUMERIC it stays exact, which matters for interest and growth calculations: `POW(NUMERIC '1.05', 3)` is exactly 1.157625.

BigQuery has no exponent operator. `2 ^ 3` is valid SQL but returns 1, because `^` is bitwise XOR, so queries ported from PostgreSQL silently produce wrong numbers. `2 ** 3` fails with a [syntax error](https://mastheadata.com/bigquery/errors/syntax-error-expected-end-of-input.md).

POW fails with `Floating point error in function` when the result overflows (`POW(10, 400)`), when a negative base gets a fractional exponent (`POW(-8, 1/3)`), or when 0 is raised to a negative power. `SAFE.POW` returns NULL in those cases. For square roots, [SQRT](https://mastheadata.com/bigquery/functions/sqrt.md) reads better than `POW(x, 0.5)`.

## Syntax

```
POW(X, Y)

POWER(X, Y)
```

## Arguments and return value

| Argument | Description |
| --- | --- |
| `X` | The base: INT64, NUMERIC, BIGNUMERIC or FLOAT64. |
| `Y` | The exponent, same types. A fractional exponent needs a base of 0 or more. |

**Returns:** FLOAT64 when either argument is FLOAT64 or both are INT64. Otherwise NUMERIC, or BIGNUMERIC when either argument is BIGNUMERIC.

## Examples

### Powers with INT64 and NUMERIC inputs

```
SELECT
  POW(2, 10) AS two_to_the_10th,
  POWER(10, -2) AS hundredth,
  POW(NUMERIC '1.05', 2) AS numeric_power;
```

Result
| two\_to\_the\_10th | hundredth | numeric\_power |
| --- | --- | --- |
| 1024.0 | 0.01 | 1.1025 |

### Compound growth with exact decimals

1000 at 5% a year for three years. NUMERIC keeps the calculation exact until the final ROUND.

```
SELECT
  ROUND(NUMERIC '1000' * POW(NUMERIC '1.05', 3), 2) AS balance_after_3_years;
```

Result
| balance\_after\_3\_years |
| --- |
| 1157.63 |

### Convert bytes billed to TiB

On-demand queries are billed per TiB, which is 2^40 bytes; see [BigQuery pricing](https://mastheadata.com/bigquery/pricing.md) for the rate.

```
WITH jobs AS (
  SELECT 'daily_rollup' AS job, 2199023255552 AS total_bytes_billed UNION ALL
  SELECT 'adhoc_export', 274877906944
)
SELECT
  job,
  total_bytes_billed / POW(1024, 4) AS tib_billed
FROM jobs
ORDER BY job;
```

Result
| job | tib\_billed |
| --- | --- |
| adhoc\_export | 0.25 |
| daily\_rollup | 2.0 |

### ^ is XOR, not a power

In binary, 2 is 010 and 3 is 011; XOR gives 001.

```
SELECT
  2 ^ 3 AS bitwise_xor,
  POW(2, 3) AS power;
```

Result
| bitwise\_xor | power |
| --- | --- |
| 1 | 8.0 |

## Common mistakes

*   Using `^` for exponents as in PostgreSQL. In BigQuery `2 ^ 3` is bitwise XOR and returns 1; use `POW(2, 3)`.
*   Expecting an INT64 result. `POW(2, 3)` is 8.0; cast it if you need an integer, or multiply (`x * x`) to stay in INT64.
*   Taking roots of negative numbers with fractional exponents. `POW(-8, 1/3)` fails with Floating point error in function; use `CBRT(x)` for cube roots or `SIGN(x) * POW(ABS(x), 1/3)`.
*   Doing money math in FLOAT64. Compounding with FLOAT64 accumulates binary rounding errors; use NUMERIC for rates and balances.

## FAQ

What is the difference between POW and POWER in BigQuery?

None. POWER is a synonym for POW, with the same arguments and return types.

How do I square a number in BigQuery?

`POW(x, 2)` returns FLOAT64 for INT64 input. `x * x` keeps INT64 but overflows once x passes about 3 billion.

Is there an exponent operator in BigQuery?

No. `^` is bitwise XOR and `**` is a syntax error. Use POW or POWER, or EXP for powers of e.

## Related

[SQRT](https://mastheadata.com/bigquery/functions/sqrt.md)[LOG, LN, LOG10](https://mastheadata.com/bigquery/functions/log.md)[ROUND](https://mastheadata.com/bigquery/functions/round.md)[ABS](https://mastheadata.com/bigquery/functions/abs.md)[CAST](https://mastheadata.com/bigquery/functions/cast.md)[SAFE\DIVIDE](https://mastheadata.com/bigquery/functions/safe-divide.md)

### Errors you may hit

[Syntax error: Expected end of input but got](https://mastheadata.com/bigquery/errors/syntax-error-expected-end-of-input.md)

### More mathematical functions

[CEIL / CEILING](https://mastheadata.com/bigquery/functions/ceil.md)[DIV](https://mastheadata.com/bigquery/functions/div.md)[FLOOR](https://mastheadata.com/bigquery/functions/floor.md)[GREATEST](https://mastheadata.com/bigquery/functions/greatest.md)[LEAST](https://mastheadata.com/bigquery/functions/least.md)[MOD](https://mastheadata.com/bigquery/functions/mod.md)[RAND](https://mastheadata.com/bigquery/functions/rand.md)[RANGE\BUCKET](https://mastheadata.com/bigquery/functions/range-bucket.md)[TRUNC](https://mastheadata.com/bigquery/functions/trunc.md)

[All BigQuery mathematical functions](https://mastheadata.com/bigquery/math-functions.md) · [All functions](https://mastheadata.com/bigquery/functions.md) · [BigQuery error messages](https://mastheadata.com/bigquery/errors.md)
---

## Other pages in functions

> For the full index of this section, see [BigQuery Reference](https://mastheadata.com/llms/llms-bigquery-reference.txt).

- [BigQuery ABS: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/abs.md): ABS(x) returns the absolute value of x with the same type as the input: ABS(-42) is 42. Use it for distances and tolerances, such as ABS(ledger_amount - bank_amount) > 1, and for day gaps in either order. ABS of the smallest INT64 value fails with an integer overflow.
- [BigQuery ANY_VALUE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/any-value.md): ANY_VALUE returns the value of an expression from some row of the group, skipping NULLs. Use it for columns that are the same on every row of a group, such as a customer name next to the customer ID, or with HAVING MAX/MIN to take a value from the row with the highest or lowest key.
- [BigQuery APPROX_COUNT_DISTINCT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/approx-count-distinct.md): APPROX_COUNT_DISTINCT estimates the number of distinct non-NULL values with a HyperLogLog++ sketch. On large, high-cardinality columns it needs far less memory and slot time than COUNT(DISTINCT), at the cost of a small error. Use it for dashboards and exploration, not for billing.
- [BigQuery APPROX_QUANTILES: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/approx-quantiles.md): APPROX_QUANTILES(x, n) returns an array of n + 1 approximate quantile boundaries, from the minimum to the maximum. APPROX_QUANTILES(x, 100)[OFFSET(50)] is the median and [OFFSET(95)] the 95th percentile; unlike PERCENTILE_CONT it works in GROUP BY queries.
- [BigQuery APPROX_TOP_COUNT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/approx-top-count.md): APPROX_TOP_COUNT(x, n) returns the n most frequent values of x with their approximate counts, as an ARRAY of STRUCT<value, count>. Use it for top pages, top error codes and skewed join keys. Unlike most aggregates it counts NULL as a value.
- [BigQuery ARRAY_AGG: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/array-agg.md): ARRAY_AGG collects the values of a group into an ARRAY. With ORDER BY and LIMIT inside the call it keeps the latest row per key: ARRAY_AGG(t ORDER BY updated_at DESC LIMIT 1)[OFFSET(0)]. Add IGNORE NULLS, because an array with a NULL element fails the query.
- [BigQuery ARRAY_CONCAT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/array-concat.md): ARRAY_CONCAT(arr1, arr2, ...) joins two or more arrays of the same element type into one, keeping order and duplicates. It returns NULL if any input is NULL, so wrap nullable arrays in IFNULL(arr, []). The || operator does the same.
- [BigQuery ARRAY_FIRST: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/array-first.md): ARRAY_FIRST(arr) returns the first element of an array, typed as the array's elements. It returns NULL for a NULL array but raises an error for an empty one, so use arr[SAFE_OFFSET(0)] when arrays can be empty.
- [BigQuery ARRAY_LAST: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/array-last.md): ARRAY_LAST(arr) returns the last element of an array without the ARRAY_LENGTH(arr) - 1 arithmetic. It returns NULL for a NULL array and raises an error for an empty one. Pair it with SPLIT to get the last part of a path or URL.
- [BigQuery ARRAY_LENGTH: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/array-length.md): ARRAY_LENGTH(arr) returns the number of elements in an array as INT64: 0 for an empty array and NULL for a NULL array. Use it to count items per row, find rows with empty arrays, or compute the offset of the last element.
- [BigQuery ARRAY_REVERSE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/array-reverse.md): ARRAY_REVERSE(arr) returns the same array with its elements in the opposite order. Use it to read event paths or histories newest first, or together with ARRAY_SLICE to take the most recent N items.
- [BigQuery ARRAY_SLICE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/array-slice.md): ARRAY_SLICE(arr, start_offset, end_offset) returns the elements between two zero-based offsets, both ends included. Negative offsets count from the end, so ARRAY_SLICE(arr, -3, -1) returns the last three elements.
- [BigQuery ARRAY_TO_STRING: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/array-to-string.md): ARRAY_TO_STRING(arr, delimiter[, null_text]) joins the elements of a STRING or BYTES array into one string. NULL elements are skipped unless you pass null_text. Use it to turn tags, page paths or ID lists into readable text.
- [BigQuery ARRAY: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/array.md): ARRAY(subquery) collects the rows a subquery returns into an array, one element per row, and returns an empty array (never NULL) when there are no rows. Use it to build array columns, or to filter and reshape an existing array with ARRAY(SELECT ... FROM UNNEST(arr)).
- [BigQuery AVG: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/avg.md): AVG returns the mean of the non-NULL values in a group. INT64 input returns FLOAT64 and NUMERIC returns NUMERIC. With OVER and a ROWS or RANGE frame it computes moving averages, such as a 7-day average of daily signups.
- [BigQuery CASE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/case.md): CASE returns the result of the first WHEN branch that matches. The simple form compares one value with a list (CASE status WHEN 'P' THEN 'pending' END); the searched form tests conditions (CASE WHEN amount >= 1000 THEN 'large' END). Use it to relabel, bucket or conditionally aggregate rows.
- [BigQuery CAST: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/cast.md): CAST(expression AS type) converts a value to another data type, such as STRING to INT64 or TIMESTAMP to DATE, and fails the whole query if any value can't be converted. Add a FORMAT clause to parse or print dates, numbers and bytes in a specific layout.
- [BigQuery CEIL / CEILING: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/ceil.md): CEIL(x) returns the smallest whole number that is not less than x: CEIL(2.1) is 3.0 and CEIL(-2.9) is -2.0. CEILING is a synonym. INT64 and FLOAT64 inputs return FLOAT64, so cast the result when you need an integer count such as billable minutes.
- [BigQuery COALESCE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/coalesce.md): COALESCE(expr1, expr2, ...) returns the first argument that is not NULL, or NULL if every argument is NULL. Use it for fallback chains such as COALESCE(updated_at, created_at) and to merge key columns after a FULL OUTER JOIN.
- [BigQuery CONCAT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/concat.md): CONCAT joins two or more values into one STRING (or BYTES): CONCAT(first_name, ' ', last_name). The || operator does the same. Both return NULL if any input is NULL, so wrap nullable columns in IFNULL or use ARRAY_TO_STRING to skip them.
- [BigQuery CONTAINS_SUBSTR: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/contains-substr.md): CONTAINS_SUBSTR(expression, 'text') returns TRUE if the text appears anywhere in the value, ignoring case and Unicode differences. It also searches every field of a STRUCT, ARRAY or whole row: WHERE CONTAINS_SUBSTR(t, 'timeout') checks all columns.
- [BigQuery COUNT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/count.md): COUNT counts rows: COUNT() counts every row, COUNT(column) skips NULLs, and COUNT(DISTINCT column) counts unique non-NULL values exactly. Use it for row counts, completeness checks and unique users per day.
- [BigQuery COUNTIF: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/countif.md): COUNTIF counts the rows where a BOOL condition is TRUE, for example COUNTIF(status = 'failed'). Use it for conditional counts and failure rates; several COUNTIFs in one GROUP BY give side-by-side metrics. FALSE and NULL are not counted.
- [BigQuery CURRENT_DATE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/current-date.md): CURRENT_DATE() returns today's date as a DATE, in UTC unless you pass a time zone: CURRENT_DATE('America/New_York'). Use it for "today", "yesterday" (CURRENT_DATE() - 1) and rolling date filters.
- [BigQuery CURRENT_DATETIME: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/current-datetime.md): CURRENT_DATETIME() returns the current date and time as a DATETIME, the wall-clock time in UTC or in the time zone you pass: CURRENT_DATETIME('Europe/Berlin'). Use it for local business times; use CURRENT_TIMESTAMP for event times.
- [BigQuery CURRENT_TIMESTAMP: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/current-timestamp.md): CURRENT_TIMESTAMP() returns the current instant as a TIMESTAMP with microsecond precision, shown in UTC. Use it for load times, freshness checks and "last N hours" filters; it takes no time zone argument.
- [BigQuery DATE_ADD: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/date-add.md): DATE_ADD(date, INTERVAL n part) adds days, weeks, months, quarters or years to a DATE and returns a DATE. Adding a month to January 31 returns the last day of February, not March 3.
- [BigQuery DATE_BUCKET: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/date-bucket.md): DATE_BUCKET(date, INTERVAL n DAY) returns the first day of the fixed-width bucket that contains a date, counted from an origin (1950-01-01 by default). Use it for 7-day, 14-day or N-month periods that DATE_TRUNC can't express.
- [BigQuery DATE_DIFF: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/date-diff.md): DATE_DIFF(end_date, start_date, DAY) returns the number of days between two dates as INT64. For WEEK, MONTH and YEAR it counts calendar boundaries crossed, so January 31 to February 1 is one month.
- [BigQuery DATE_FROM_UNIX_DATE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/date-from-unix-date.md): DATE_FROM_UNIX_DATE(n) converts a count of days since 1970-01-01 into a DATE: DATE_FROM_UNIX_DATE(20780) is 2026-11-23. Use it for columns that store dates as day numbers, such as Avro date fields read as integers.
- [BigQuery DATE_SUB: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/date-sub.md): DATE_SUB(date, INTERVAL n part) subtracts days, weeks, months, quarters or years from a DATE. DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) is yesterday; month subtraction clamps to the last day of shorter months.
- [BigQuery DATE_TRUNC: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/date-trunc.md): DATE_TRUNC rounds a date down to the start of a period: DATE_TRUNC(order_date, MONTH) returns the first day of that month. It also truncates DATETIME and TIMESTAMP values. Use it to group rows by week, month, quarter or year.
- [BigQuery DATE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/date.md): DATE builds a DATE from year, month and day numbers, or converts a TIMESTAMP or DATETIME to its calendar date. DATE(ts, 'America/New_York') returns the local date of a timestamp; without a time zone it uses UTC.
- [BigQuery DATETIME_ADD: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/datetime-add.md): DATETIME_ADD(datetime, INTERVAL n part) adds microseconds up to years to a DATETIME and returns a DATETIME. It works on wall-clock time, so adding 1 DAY keeps the same local hour even across a daylight saving change.
- [BigQuery DATETIME_DIFF: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/datetime-diff.md): DATETIME_DIFF(end, start, part) returns the number of part boundaries between two DATETIME values as INT64. Unlike TIMESTAMP_DIFF, it counts boundaries for every part: 23:55 to 00:05 is 1 DAY and 1 HOUR.
- [BigQuery DATETIME_SUB: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/datetime-sub.md): DATETIME_SUB(datetime, INTERVAL n part) subtracts microseconds up to years from a DATETIME and returns a DATETIME. Use it for local-time windows such as "the last 2 hours in store time"; month steps clamp to month ends.
- [BigQuery DATETIME_TRUNC: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/datetime-trunc.md): DATETIME_TRUNC(datetime, part) rounds a DATETIME down to the start of a period, such as the hour, day, week or month. Use it to group local wall-clock times into hourly or daily buckets.
- [BigQuery DATETIME: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/datetime.md): DATETIME builds a DATETIME from numbers, from a DATE and TIME, or converts a TIMESTAMP to local wall-clock time: DATETIME(ts, 'Europe/Berlin'). It is the usual way to convert a UTC timestamp to a local time zone in BigQuery.
- [BigQuery DENSE_RANK: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/dense-rank.md): DENSE_RANK() ranks rows within a window partition without gaps: tied rows share a rank and the next distinct value gets the next integer (1, 1, 2). Use it for 'Nth highest value' queries and to number distinct values, such as the days a user was active.
- [BigQuery DIV: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/div.md): DIV(x, y) divides two integers and drops the remainder: DIV(7, 2) is 3, while 7 / 2 is 3.5. It returns INT64 for INT64 input and truncates toward zero, so DIV(-7, 2) is -3. Use it for integer division, batch numbers and unit conversions.
- [BigQuery ENDS_WITH: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/ends-with.md): ENDS_WITH(value, suffix) returns TRUE if a string ends with suffix: ENDS_WITH(file_name, '.parquet') finds Parquet files. It is case-sensitive, treats every character literally and returns NULL for NULL input.
- [BigQuery ERROR: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/error.md): ERROR(message) stops the query with your own error message. Use it inside IF or CASE to fail a query when a data check doesn't pass, such as an empty partition or a duplicate key, so scheduled queries and pipelines stop instead of writing bad data.
- [BigQuery EXTRACT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/extract.md): EXTRACT(part FROM value) returns one part of a DATE, DATETIME, TIMESTAMP or TIME, such as YEAR, MONTH, DAYOFWEEK, ISOWEEK or HOUR, usually as INT64. For a TIMESTAMP, add AT TIME ZONE to read the part in local time.
- [BigQuery FARM_FINGERPRINT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/farm-fingerprint.md): FARM_FINGERPRINT(value) hashes a STRING or BYTES value to a signed INT64 that never changes between runs. Use it for repeatable sampling, A/B assignment, sharding and compact surrogate keys, usually as ABS(MOD(FARM_FINGERPRINT(id), n)). It is fast but not cryptographic.
- [BigQuery FIRST_VALUE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/first-value.md): FIRST_VALUE(x) returns x from the first row of the current window frame, such as each session's landing page or a series' starting value. With IGNORE NULLS it returns the first non-NULL value; an ORDER BY in the OVER clause is required.
- [BigQuery FLOOR: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/floor.md): FLOOR(x) returns the largest whole number that is not greater than x: FLOOR(2.9) is 2.0 and FLOOR(-2.1) is -3.0. Use it to round down and to build fixed-width bins and time buckets that stay correct for negative values. INT64 and FLOAT64 inputs return FLOAT64.
- [BigQuery FORMAT_DATE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/format-date.md): FORMAT_DATE(format_string, date) turns a DATE into a STRING using % elements: FORMAT_DATE('%d/%m/%Y', d) gives 23/11/2026 and FORMAT_DATE('%B %Y', d) gives November 2026. Use it for labels, file names and display formats.
- [BigQuery FORMAT_DATETIME: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/format-datetime.md): FORMAT_DATETIME(format_string, datetime) turns a DATETIME into a STRING using % elements, for example FORMAT_DATETIME('%d/%m/%Y %H:%M', dt) gives 23/11/2026 18:45. Use it for display labels and file names.
- [BigQuery FORMAT_TIMESTAMP: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/format-timestamp.md): FORMAT_TIMESTAMP(format_string, ts[, time_zone]) converts a TIMESTAMP to a STRING with % elements, in UTC or in the zone you pass: FORMAT_TIMESTAMP('%F %H:%M', ts, 'Europe/Berlin'). It is the standard way to turn a timestamp into a local-time string.
- [BigQuery FORMAT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/format.md): FORMAT(pattern, values...) builds a string with printf-style specifiers: FORMAT('%.2f', 3.14159) returns 3.14, FORMAT("%'d", 1234567) returns 1,234,567 and FORMAT('%s has %d orders', name, n) fills in text. Use %t to print any type.
- [BigQuery GENERATE_ARRAY: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/generate-array.md): GENERATE_ARRAY(start, end[, step]) returns an array of numbers from start to end, both inclusive, stepping by 1 or by step. Wrap it in UNNEST to get a number series as rows for gap filling, bucketing or test data, without a numbers table.
- [BigQuery GENERATE_DATE_ARRAY: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/generate-date-array.md): GENERATE_DATE_ARRAY(start, end[, INTERVAL n part]) returns an ARRAY of dates from start to end, both included. UNNEST it to build a calendar (date spine) and LEFT JOIN your data so days without rows still appear.
- [BigQuery GENERATE_UUID: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/generate-uuid.md): GENERATE_UUID() returns a random version 4 UUID as a lowercase 36-character STRING, such as 3f2b8c1e-9d4a-4e7b-8c21-5a6f0d9e7b13. Use it to give new rows unique IDs. Every call and every run returns a new value, so it is not a stable key for re-runnable pipelines.
- [BigQuery GREATEST: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/greatest.md): GREATEST(x1, x2, ...) returns the largest of its arguments within a single row, for example the latest of several date columns. If any argument is NULL, the result is NULL, unlike PostgreSQL. To find the maximum across rows, use MAX instead.
- [BigQuery IF: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/if.md): IF(condition, true_result, else_result) returns true_result when the condition is TRUE and else_result when it is FALSE or NULL. Use it for two-way logic inside a query, such as flags and guarded calculations; switch to CASE for three or more branches.
- [BigQuery IFNULL: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/ifnull.md): IFNULL(expr, null_result) returns expr, or null_result when expr is NULL. Use it to replace NULLs with a default such as 0 or 'unknown'. It is identical to COALESCE(expr, null_result) and is BigQuery's version of NVL and ISNULL.
- [BigQuery INITCAP: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/initcap.md): INITCAP(value[, delimiters]) capitalizes the first letter of each word and lowercases the rest: INITCAP('mary-jane SMITH') returns Mary-Jane Smith. An optional second argument sets which characters separate words.
- [BigQuery INSTR: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/instr.md): INSTR(value, subvalue[, position[, occurrence]]) returns the 1-based position of a substring, optionally starting at a given position or finding the nth match. INSTR(path, '/', -1) finds the last slash; it returns 0 when there is no match.
- [BigQuery JSON_EXTRACT_ARRAY: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/json-extract-array.md): JSON_EXTRACT_ARRAY(json[, json_path]) converts a JSON array into a SQL ARRAY with one element per item, as JSON-formatted strings (or JSON values for JSON input), ready for UNNEST. It is deprecated; JSON_QUERY_ARRAY returns the same result.
- [BigQuery JSON_EXTRACT_SCALAR: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/json-extract-scalar.md): JSON_EXTRACT_SCALAR(json, json_path) returns a scalar JSON value (string, number or boolean) as a SQL STRING without quotes, and NULL for objects, arrays and JSON null. It is deprecated: JSON_VALUE behaves the same and is the recommended replacement.
- [BigQuery JSON_EXTRACT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/json-extract.md): JSON_EXTRACT(json, json_path) returns the JSON at a path (an object, an array or a quoted string) as JSON-formatted text, or as JSON for JSON input. Google marks it deprecated: JSON_QUERY returns the same values and is the function to use in new code.
- [BigQuery JSON_KEYS: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/json-keys.md): JSON_KEYS(json[, max_depth][, mode => ...]) returns the unique keys of a JSON value as a sorted ARRAY<STRING>, with nested keys as dotted paths such as user.id. Use it to discover and compare the schemas of semi-structured payloads.
- [BigQuery JSON_QUERY_ARRAY: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/json-query-array.md): JSON_QUERY_ARRAY(json[, json_path]) turns a JSON array into a SQL ARRAY with one element per item: ARRAY<JSON> for JSON input, JSON-formatted strings for STRING input. Combine it with UNNEST to get one row per item of a nested JSON list.
- [BigQuery JSON_QUERY: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/json-query.md): JSON_QUERY(json, json_path) returns the JSON value at a path (object, array or scalar) as JSON text for STRING input or as JSON for JSON input, keeping quotes on strings. Use it to pull nested objects and arrays; use JSON_VALUE for plain scalars.
- [BigQuery JSON_REMOVE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/json-remove.md): JSON_REMOVE(json, path[, path ...]) returns a copy of a JSON value with the data at each JSONPath removed, whether an object key or an array element. Paths that don't exist are ignored. Use it to strip personal data or bulky debug fields from JSON columns.
- [BigQuery JSON_SET: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/json-set.md): JSON_SET(json, path, value[, path, value ...]) returns a copy of a JSON value with values inserted or replaced at the given JSONPaths, creating missing parents along the way. Pass create_if_missing => FALSE to update only keys that already exist.
- [BigQuery JSON_TYPE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/json-type.md): JSON_TYPE(json) returns the type of a JSON value as a string: object, array, string, number, boolean or null. Use it to profile inconsistent payloads, tell a JSON null from a missing key, and pick the right conversion for each row.
- [BigQuery JSON_VALUE_ARRAY: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/json-value-array.md): JSON_VALUE_ARRAY(json[, json_path]) extracts a JSON array of scalars as an ARRAY<STRING> with the quotes removed. Use it for tag lists, IDs and flags stored in JSON; it returns NULL if any element is an object or an array.
- [BigQuery JSON_VALUE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/json-value.md): JSON_VALUE(json[, json_path]) extracts a scalar (string, number or boolean) from JSON and returns it as a SQL STRING without quotes; objects, arrays and JSON null return NULL. It is the recommended replacement for JSON_EXTRACT_SCALAR and works on STRING and JSON input.
- [BigQuery LAG: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/lag.md): LAG(value, offset, default) returns a value from an earlier row of the window partition, the previous row by default. Use it for day-over-day changes, time since the previous event and gap detection. In BigQuery it has no IGNORE NULLS option.
- [BigQuery LAST_DAY: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/last-day.md): LAST_DAY(date) returns the last day of the month that contains a date, such as 2026-11-30 for 2026-11-23. Pass QUARTER, YEAR, WEEK, ISOWEEK or ISOYEAR as a second argument for the last day of other periods.
- [BigQuery LAST_VALUE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/last-value.md): LAST_VALUE(x) returns x from the last row of the current window frame. With ORDER BY and no frame clause the frame ends at the current row, so it returns the current value, not the partition's last one; add ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.
- [BigQuery LEAD: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/lead.md): LEAD(value, offset, default) returns a value from a later row of the window partition, the next row by default. Use it for the time to the next event, valid-from and valid-to ranges, and funnel steps. The last row of each partition gets the default, or NULL.
- [BigQuery LEAST: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/least.md): LEAST(x1, x2, ...) returns the smallest of its arguments within a single row, such as the earliest of several dates or a value capped at a limit. If any argument is NULL, the result is NULL. Use MIN to find the smallest value across rows.
- [BigQuery LEFT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/left.md): LEFT(value, length) returns the first length characters of a string (or bytes of a BYTES value): LEFT('4111111111111111', 4) returns 4111. If the value is shorter, LEFT returns it whole; a negative length is an error.
- [BigQuery LENGTH: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/length.md): LENGTH(value) returns the number of characters in a STRING, or the number of bytes in a BYTES value. CHAR_LENGTH counts characters too; BYTE_LENGTH counts the UTF-8 bytes of a string, which differ for accented letters, non-Latin scripts and emoji.
- [BigQuery LOG, LN, LOG10: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/log.md): LOG(x) returns the natural logarithm of x (the same as LN), LOG(x, base) uses any base, and LOG10(x) uses base 10. INT64 input returns FLOAT64, and x <= 0 fails. Watch out when porting: PostgreSQL's one-argument log is base 10, and Snowflake puts the base first.
- [BigQuery LOGICAL_AND: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/logical-and.md): LOGICAL_AND returns TRUE if a BOOL expression is TRUE for every non-NULL row of a group and FALSE if any row is FALSE. Use it for checks such as 'did every task of this run succeed'. NULLs are ignored, and an empty or all-NULL group returns NULL.
- [BigQuery LOGICAL_OR: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/logical-or.md): LOGICAL_OR returns TRUE if a BOOL expression is TRUE for at least one row of a group and FALSE if every non-NULL row is FALSE. Use it for 'did anything fail' or 'did this session purchase'. NULLs are ignored; an empty or all-NULL group returns NULL.
- [BigQuery LOWER: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/lower.md): LOWER(value) converts a string to lowercase using Unicode case rules: LOWER('Ana@Example.COM') returns ana@example.com. Use it to normalize emails, codes and free text before comparing, grouping or joining.
- [BigQuery LPAD: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/lpad.md): LPAD(value, length[, pattern]) pads a string on the left to a fixed length: LPAD('42', 6, '0') returns 000042. The default pattern is a space. If the value is already longer, LPAD truncates it to length.
- [BigQuery LTRIM: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/ltrim.md): LTRIM(value[, characters]) removes leading whitespace, or every leading character found in the characters set: LTRIM('000123', '0') returns 123. It works like TRIM but only on the start of the string.
- [BigQuery MAX_BY: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/max-by.md): MAX_BY(x, y) returns the value of x from the row where y is largest, such as the current status of each order: MAX_BY(status, updated_at). It is a synonym for ANY_VALUE(x HAVING MAX y) and replaces a self-join or a ROW_NUMBER subquery.
- [BigQuery MAX: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/max.md): MAX returns the largest non-NULL value in a group: the latest timestamp, the highest amount, the alphabetically last string. It works on any orderable type (not ARRAY or STRUCT) and is the usual way to check when a table last received data.
- [BigQuery MD5: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/md5.md): MD5(input) returns the 16-byte MD5 hash of a STRING or BYTES value as BYTES, which the console shows in base64. Wrap it in TO_HEX to get the familiar 32-character hex string. Use it for checksums and change detection, never for security.
- [BigQuery MIN_BY: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/min-by.md): MIN_BY(x, y) returns the value of x from the row where y is smallest, such as each user's first marketing channel: MIN_BY(channel, visited_at). It is a synonym for ANY_VALUE(x HAVING MIN y); rows with a NULL y are ignored and ties return any matching row.
- [BigQuery MIN: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/min.md): MIN returns the smallest non-NULL value in a group: the earliest date, the lowest price, the alphabetically first string. It works on any orderable type (not ARRAY or STRUCT), and with OVER it puts each group's minimum on every row.
- [BigQuery MOD: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/mod.md): MOD(x, y) returns the remainder of x divided by y, with the sign of x: MOD(25, 7) is 4 and MOD(-25, 7) is -4. BigQuery has no % operator, so MOD is how you write modulo, for even/odd checks, every-Nth-row filters and hash buckets.
- [BigQuery NTILE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/ntile.md): NTILE(n) splits the ordered rows of each window partition into n buckets of nearly equal size and returns the bucket number, from 1 to n. Use it for quartiles, deciles and equal-size customer segments; bucket sizes differ by at most one row.
- [BigQuery NULLIF: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/nullif.md): NULLIF(expr, expr_to_match) returns NULL when the two values are equal and expr otherwise. Its classic use is the divide-by-zero guard x / NULLIF(y, 0), which returns NULL instead of failing. It also turns placeholders such as '' or -1 into real NULLs.
- [BigQuery OFFSET and SAFE_OFFSET: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/offset.md): arr[OFFSET(n)] returns the array element at zero-based position n and fails if n is out of range; arr[SAFE_OFFSET(n)] returns NULL instead. ORDINAL(n) and SAFE_ORDINAL(n) do the same with one-based positions.
- [BigQuery PARSE_DATE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/parse-date.md): PARSE_DATE(format_string, string) converts a STRING to a DATE using % elements, such as PARSE_DATE('%d/%m/%Y', '23/11/2026'). Use SAFE.PARSE_DATE to get NULL instead of a query failure for values that don't match.
- [BigQuery PARSE_DATETIME: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/parse-datetime.md): PARSE_DATETIME(format_string, string) converts a STRING to a DATETIME using % elements, such as PARSE_DATETIME('%d/%m/%Y %H:%M', '23/11/2026 18:45'). The result has no time zone; wrap it in TIMESTAMP(..., zone) to get an instant.
- [BigQuery PARSE_JSON: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/parse-json.md): PARSE_JSON(json_string) converts JSON-formatted text into a value of the JSON type, validating it on the way. Use SAFE.PARSE_JSON to get NULL instead of an error for malformed rows, and wide_number_mode => 'round' to accept numbers too large to store exactly.
- [BigQuery PARSE_NUMERIC: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/parse-numeric.md): PARSE_NUMERIC(string) converts a STRING to NUMERIC and, unlike CAST, accepts thousands separators, spaces and a trailing minus sign, as in '1,234.50' or '75.10-'. Use it for amounts exported from spreadsheets, ERP systems and reports.
- [BigQuery PARSE_TIMESTAMP: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/parse-timestamp.md): PARSE_TIMESTAMP(format_string, string[, time_zone]) converts a STRING to a TIMESTAMP using % elements. An offset in the text (%z, %Ez) is honored; otherwise the text is read in the zone argument, or UTC by default.
- [BigQuery PERCENT_RANK: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/percent-rank.md): PERCENT_RANK() returns each row's relative rank in its window partition as a FLOAT64 from 0 to 1, computed as (rank - 1) / (rows - 1). Use it to say 'this request was slower than 90% of the others' or to flag the extreme rows of a group.
- [BigQuery PERCENTILE_CONT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/percentile-cont.md): PERCENTILE_CONT(x, p) OVER (...) returns the exact p-th percentile of x with linear interpolation, such as the median with p = 0.5. In BigQuery it is a window function only: add SELECT DISTINCT for one row per group, or use APPROX_QUANTILES in GROUP BY queries.
- [BigQuery PERCENTILE_DISC: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/percentile-disc.md): PERCENTILE_DISC(x, p) OVER (...) returns the first value of x whose cumulative distribution reaches p, so the answer is always a value from the data. It works on any orderable type, including dates and strings, and like PERCENTILE_CONT it is a window function only in BigQuery.
- [BigQuery RAND: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/rand.md): RAND() returns a pseudo-random FLOAT64 from 0 (inclusive) to 1 (exclusive), different for every row and every run. Use it for random sampling with WHERE RAND() < 0.1 and for shuffling. It takes no seed; for a repeatable sample, hash a stable key with FARM_FINGERPRINT.
- [BigQuery RANGE_BUCKET: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/range-bucket.md): RANGE_BUCKET(point, boundaries) returns the 0-based index of the bucket a value falls into, given a sorted array of boundaries: RANGE_BUCKET(25, [10, 20, 30]) is 2. Use it for histograms and custom bands, and in PARTITION BY for integer-range partitioning.
- [BigQuery RANK: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/rank.md): RANK() assigns 1-based ranks within a window partition; tied rows share a rank and the next rank skips ahead (1, 1, 3). Use it for leaderboards and top-N queries that should keep ties, such as QUALIFY RANK() OVER (ORDER BY revenue DESC) <= 3.
- [BigQuery REGEXP_CONTAINS: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/regexp-contains.md): REGEXP_CONTAINS(value, regex) returns TRUE if any part of the string matches an RE2 regular expression: REGEXP_CONTAINS(email, r'@example\.(com|org)$'). Use it when LIKE's % and _ wildcards are not enough; anchor with ^ and $ for a full match.
- [BigQuery REGEXP_EXTRACT_ALL: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/regexp-extract-all.md): REGEXP_EXTRACT_ALL(value, regex) returns an ARRAY of every non-overlapping match of an RE2 regular expression: REGEXP_EXTRACT_ALL(text, r'#(\w+)') returns all hashtags. It returns an empty array when nothing matches.
- [BigQuery REGEXP_EXTRACT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/regexp-extract.md): REGEXP_EXTRACT(value, regex) returns the first substring that matches an RE2 regular expression, or the capture group if the pattern has one: REGEXP_EXTRACT(note, r'\d+') pulls the first number from text. Optional position and occurrence arguments pick a later match.
- [BigQuery REGEXP_REPLACE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/regexp-replace.md): REGEXP_REPLACE(value, regex, replacement) replaces every match of an RE2 regular expression: REGEXP_REPLACE(phone, r'[^0-9]', '') keeps only digits. In the replacement, \1 to \9 insert capture groups and \0 the whole match.
- [BigQuery REPLACE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/replace.md): REPLACE(value, from, to) replaces every occurrence of a substring: REPLACE(phone, ' ', '') removes all spaces. Matching is exact and case-sensitive; use REGEXP_REPLACE for patterns and TRANSLATE for single characters.
- [BigQuery REVERSE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/reverse.md): REVERSE(value) returns a STRING with its characters in reverse order, or a BYTES value with its bytes reversed: REVERSE('stressed') returns desserts. For arrays, use ARRAY_REVERSE.
- [BigQuery RIGHT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/right.md): RIGHT(value, length) returns the last length characters of a string (or bytes of a BYTES value): RIGHT('4111111111111111', 4) returns 1111. Shorter values are returned whole; a negative length is an error.
- [BigQuery ROUND: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/round.md): ROUND(x, n) rounds x to n decimal places, with halfway cases going away from zero: ROUND(19.987, 2) returns 19.99. Without n it rounds to a whole number. INT64 and FLOAT64 inputs return FLOAT64; use NUMERIC for exact money values and 'ROUND_HALF_EVEN' for banker's rounding.
- [BigQuery ROW_NUMBER: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/row-number.md): ROW_NUMBER() numbers the rows of each window partition 1, 2, 3 in ORDER BY order, with no ties and no gaps. Its main use is removing duplicates: QUALIFY ROW_NUMBER() OVER (PARTITION BY id ORDER BY updated_at DESC) = 1 keeps the latest row per key.
- [BigQuery RPAD: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/rpad.md): RPAD(value, length[, pattern]) pads a string on the right to a fixed length: RPAD('SKU', 8, '.') returns SKU..... The default pattern is a space. Values longer than length are truncated to their first length characters.
- [BigQuery RTRIM: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/rtrim.md): RTRIM(value[, characters]) removes trailing whitespace, or every trailing character found in the characters set: RTRIM('12.500', '0') returns 12.5. It works like TRIM but only on the end of the string.
- [BigQuery SAFE_CAST: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/safe-cast.md): SAFE_CAST(expression AS type) works like CAST but returns NULL instead of failing when a value can't be converted. Use it to clean messy strings without one bad row stopping the query, then count the NULLs it produced to see what failed.
- [BigQuery SAFE_DIVIDE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/safe-divide.md): SAFE_DIVIDE(x, y) divides x by y like the / operator but returns NULL instead of failing when y is 0 or the division overflows. It is the shortest fix for the division by zero error. The SAFE. prefix gives most other scalar functions the same NULL-instead-of-error behavior.
- [BigQuery SESSION_USER: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/session-user.md): SESSION_USER() returns the email address of the user or service account running the query, or a principal identifier for third-party identities. Use it for audit columns, row access policies and per-user views. BigQuery has no CURRENT_USER; this is the equivalent.
- [BigQuery SHA256: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/sha256.md): SHA256(input) returns the 32-byte SHA-256 hash of a STRING or BYTES value as BYTES. Use TO_HEX(SHA256(x)) for the standard 64-character hex digest. Use it for deterministic IDs, integrity checks and pseudonymized join keys; for plain bucketing, FARM_FINGERPRINT is cheaper.
- [BigQuery SOUNDEX: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/soundex.md): SOUNDEX(value) returns a four-character phonetic code (a letter and three digits) for how a word sounds in English: SOUNDEX('Smith') and SOUNDEX('Smyth') both return S530. Use it to find or match names with spelling variations.
- [BigQuery SPLIT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/split.md): SPLIT breaks a string into an ARRAY<STRING> on a delimiter: SPLIT('a,b,c', ',') returns [a, b, c]. Take one part with [OFFSET(n)] or [SAFE_OFFSET(n)], or turn the parts into rows with UNNEST.
- [BigQuery SQRT: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/sqrt.md): SQRT(x) returns the square root of x: SQRT(16) is 4.0. INT64 and FLOAT64 inputs return FLOAT64, while NUMERIC stays NUMERIC. A negative input fails with 'Argument to SQRT cannot be negative'; SAFE.SQRT returns NULL instead.
- [BigQuery STARTS_WITH: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/starts-with.md): STARTS_WITH(value, prefix) returns TRUE if a string begins with prefix: STARTS_WITH(table_name, 'tmp_') is TRUE for tmp_orders. It is case-sensitive and, unlike LIKE 'tmp_%', treats _ and % as plain characters.
- [BigQuery STRING_AGG: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/string-agg.md): STRING_AGG concatenates the non-NULL strings of a group into one value, separated by a delimiter (a comma by default). It is BigQuery's GROUP_CONCAT or LISTAGG: put ORDER BY inside the call to sort the list, DISTINCT to drop duplicates and LIMIT to cap its length.
- [BigQuery STRPOS: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/strpos.md): STRPOS(value, subvalue) returns the 1-based position of the first occurrence of subvalue, or 0 if it isn't found: STRPOS('ana@example.com', '@') returns 4. Use it with SUBSTR to cut strings at a delimiter.
- [BigQuery SUBSTR: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/substr.md): SUBSTR(value, position[, length]) returns part of a string: SUBSTR('INV-2026-00042', 5, 4) returns 2026. Positions start at 1, and a negative position counts from the end. SUBSTRING is an alias.
- [BigQuery SUM: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/sum.md): SUM adds up the non-NULL values in a group and returns NULL, not 0, when there is nothing to add. With OVER it gives running totals and shares of a total. INT64 sums stay INT64 and fail on overflow; FLOAT64 sums can differ in the last digits between runs.
- [BigQuery TIMESTAMP_ADD: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/timestamp-add.md): TIMESTAMP_ADD(ts, INTERVAL n part) adds an exact duration to a TIMESTAMP, in MICROSECOND, MILLISECOND, SECOND, MINUTE, HOUR or DAY (24 hours). It doesn't accept WEEK, MONTH or YEAR; use DATETIME_ADD for calendar steps.
- [BigQuery TIMESTAMP_DIFF: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/timestamp-diff.md): TIMESTAMP_DIFF(end_ts, start_ts, part) returns the number of whole MICROSECOND, MILLISECOND, SECOND, MINUTE, HOUR or DAY units between two TIMESTAMPs as INT64, truncated toward zero. Use it for durations, latencies and freshness.
- [BigQuery TIMESTAMP_MILLIS: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/timestamp-millis.md): TIMESTAMP_MILLIS(n) converts milliseconds since 1970-01-01 00:00:00 UTC to a TIMESTAMP. Use it for 13-digit epoch values from JavaScript Date.now(), Kafka, Java and most event trackers.
- [BigQuery TIMESTAMP_SECONDS: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/timestamp-seconds.md): TIMESTAMP_SECONDS(n) converts Unix epoch seconds (seconds since 1970-01-01 00:00:00 UTC) to a TIMESTAMP: TIMESTAMP_SECONDS(1795392000) is 2026-11-23 00:00:00 UTC. Wrap it in DATETIME(..., zone) for local time.
- [BigQuery TIMESTAMP_SUB: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/timestamp-sub.md): TIMESTAMP_SUB(ts, INTERVAL n part) subtracts an exact duration (MICROSECOND up to DAY) from a TIMESTAMP. TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 24 HOUR) is the standard "last 24 hours" filter; MONTH and YEAR are not allowed.
- [BigQuery TIMESTAMP_TRUNC: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/timestamp-trunc.md): TIMESTAMP_TRUNC(ts, part[, time_zone]) rounds a TIMESTAMP down to the start of a minute, hour, day, week, month or year, in UTC or in the zone you pass. Use it to group events per hour or per local day.
- [BigQuery TIMESTAMP: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/timestamp.md): TIMESTAMP converts a STRING, DATE or DATETIME to a TIMESTAMP, reading it in UTC or in the time zone you pass: TIMESTAMP('2026-11-23 09:00:00', 'Europe/Berlin') is 08:00 UTC. Use it to turn local times into absolute instants.
- [BigQuery TO_JSON_STRING: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/to-json-string.md): TO_JSON_STRING(value[, pretty_print]) serializes any SQL value, from a scalar to a struct, an array or a whole row, into JSON text. Use it to export rows as JSON, build API payloads, or compare and deduplicate entire rows.
- [BigQuery TO_JSON: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/to-json.md): TO_JSON(value) converts a SQL value (scalar, struct, array or whole row) into a value of the JSON type. Use it to build JSON columns and nested payloads you can keep querying with dot access; use TO_JSON_STRING when you need text.
- [BigQuery TRANSLATE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/translate.md): TRANSLATE(value, source_chars, target_chars) replaces each character in source_chars with the character at the same position in target_chars, and deletes source characters that have no counterpart: TRANSLATE(phone, '()- ', '') strips four characters in one call.
- [BigQuery TRIM: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/trim.md): TRIM(value[, characters]) removes leading and trailing whitespace from a string, or every leading and trailing character found in the characters set: TRIM('xxapplexx', 'x') returns apple. LTRIM and RTRIM trim one side only.
- [BigQuery TRUNC: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/trunc.md): TRUNC(x, n) cuts x to n decimal places by rounding toward zero: TRUNC(2.789, 2) is 2.78 and TRUNC(-2.789, 2) is -2.78. Without n it drops the fractional part. It never rounds up and never overflows. TRUNC is for numbers only; truncate dates with DATE_TRUNC.
- [BigQuery UNIX_DATE: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/unix-date.md): UNIX_DATE(date) returns the number of days since 1970-01-01 as INT64: UNIX_DATE(DATE '2026-11-23') is 20780. Use it for integer day keys and for formats that store dates as days since the Unix epoch.
- [BigQuery UNIX_MILLIS: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/unix-millis.md): UNIX_MILLIS(ts) returns the number of milliseconds since 1970-01-01 00:00:00 UTC as INT64, truncating microseconds. Use it to send timestamps to JavaScript, Kafka or APIs that expect epoch milliseconds.
- [BigQuery UNIX_SECONDS: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/unix-seconds.md): UNIX_SECONDS(ts) returns the number of seconds since 1970-01-01 00:00:00 UTC as INT64, dropping fractions of a second. It is BigQuery's answer to EXTRACT(EPOCH FROM ts) and UNIX_TIMESTAMP().
- [BigQuery UNNEST: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/unnest.md): UNNEST turns an array into a table with one row per element. Use FROM t CROSS JOIN UNNEST(t.arr) to flatten an array column, LEFT JOIN UNNEST to keep rows whose array is empty or NULL, and WITH OFFSET to get each element's position.
- [BigQuery UPPER: Syntax, Examples and Gotchas | Masthead](https://mastheadata.com/bigquery/functions/upper.md): UPPER(value) converts a string to uppercase using Unicode case rules: UPPER('de-be') returns DE-BE. Use it to normalize codes such as country, currency and SKU values before comparing, grouping or joining.
- [BigQuery Functions List: Syntax and Examples for Every Function | Masthead](https://mastheadata.com/bigquery/functions.md): All 143 BigQuery SQL functions we cover, by category: date, timestamp, string, array, JSON, aggregate, window and more. Each with syntax, runnable examples, common mistakes and cost notes.
