---
title: time_to_seconds function
description: Learn the syntax of the time\_to\_seconds function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/gcp/en/sql/language-manual/functions/time_to_seconds
---

# `time_to_seconds` function

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

> [!NOTE]
>
> Databricks Runtime 18 is newer than Databricks Runtime 18.0, 18.1, and 18.2. Features that would previously have shipped as a later numbered version now ship as dated updates to Databricks Runtime 18 instead. For details, see [About unified release notes](https://docs.databricks.com/gcp/en/release-notes/runtime/18.md#unified-format).

Returns the number of seconds since midnight for a [TIME](https://docs.databricks.com/gcp/en/sql/language-manual/data-types/time-type.md) value.

## Syntax

```
time_to_seconds(expr)
```

## Arguments

* `expr`: A [TIME](https://docs.databricks.com/gcp/en/sql/language-manual/data-types/time-type.md) expression.

## Returns

A `DECIMAL`. Fractional seconds are preserved in the decimal portion.

## Examples

```sql
> SELECT time_to_seconds(TIME'14:30:00.5');
  52200.500000

> SELECT time_to_seconds(TIME'00:00:00');
  0.000000
```

## Related functions

* [`time_to_millis` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/time_to_millis.md)
* [`time_to_micros` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/time_to_micros.md)
* [`time_from_seconds` function](https://docs.databricks.com/gcp/en/sql/language-manual/functions/time_from_seconds.md)
* [`TIME` type](https://docs.databricks.com/gcp/en/sql/language-manual/data-types/time-type.md)
