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

# `try_divide` 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 10.4 LTS and above

Returns `dividend` divided by `divisor`.

## Syntax

```
try_divide(dividend, divisor)
```

## Arguments

* `dividend`: A numeric or `INTERVAL` expression.
* `divisor`: A numeric expression.

## Returns

For DECFLOAT inputs, the result is `DECFLOAT(16)` when both inputs are `DECFLOAT(16)`, and `DECFLOAT(34)` otherwise. Division by zero produces infinity or NaN rather than `NULL`.

If both `dividend` and `divisor` are `DECIMAL`, the result is `DECIMAL`.

If `dividend` is a year-month interval, the result is an `INTERVAL YEAR TO MONTH`.

If `dividend` is a day-time interval, the result is an `INTERVAL DAY TO SECOND`.

In all other cases, a `DOUBLE`.

For inputs other than DECFLOAT, if the `divisor` is 0, the operator returns `NULL`.

## Examples

```sql
> SELECT try_divide(3, 2);
 1.5

> SELECT try_divide(2L, 2L);
 1.0

> SELECT try_divide(INTERVAL '3:15' HOUR TO MINUTE, 3);
 0 01:05:00.000000

> SELECT try_divide(3 , 0)
  NULL
```

## Related functions

* [`*` (asterisk sign) operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/asterisksign.md)
* [`div` operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/div.md)
* [`-` (minus sign) operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/minussign.md)
* [`+` (plus sign) operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/plussign.md)
* [`sum` aggregate function](https://docs.databricks.com/aws/en/sql/language-manual/functions/sum.md)
* [`try_add` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/try_add.md)
