---
title: bit_get function
description: Learn the syntax of the bit\_get function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/bit_get
---

# `bit_get` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 11.3 LTS and above

Returns the value of a bit in a binary representation of an integral numeric. This function is a synonym for [`getbit` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/getbit.md).

## Syntax

```
bit_get(expr, pos))
```

## Arguments

* `expr`: An expression that evaluates to an integral numeric.
* `pos`: An expression of type INTEGER.

## Returns

The result type is an INTEGER.

The result value is 1 if the bit is set, 0 otherwise.

Bits are counted right to left and 0-based.

If `pos` is outside the bounds of the data type of `expr` Databricks raises an [INVALID\_PARAMETER\_VALUE](https://docs.databricks.com/aws/en/error-messages/invalid-parameter-value-error-class.md) error.

## Common error conditions

* [INVALID\_PARAMETER\_VALUE](https://docs.databricks.com/aws/en/error-messages/invalid-parameter-value-error-class.md)

## Examples

```sql
> SELECT hex(23Y), bit_get(23Y, 3);
 0

> SELECT hex(23Y), bit_get(23Y, 0);
 1

> SELECT bit_get(23Y, 8);
 Error: INVALID_PARAMETER_VALUE.BIT_POSITION_RANGE

> SELECT bit_get(23Y, -1);
 Error: INVALID_PARAMETER_VALUE.BIT_POSITION_RANGE
```

## Related functions

* [`bit_reverse` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/bit_reverse.md)
* [`getbit` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/getbit.md)
* [`~` (tilde sign) operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/tildesign.md)
