> For the complete documentation index, see [llms.txt](https://docs.wem.io/platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wem.io/platform/wemreference/functions/date/toduration.md).

# ToDuration

{% hint style="info" %}
The **`ToDuration()`** function converts provided input to a specific Duration value. Possible values are a string ("dd.HH:mm:ss.fff"), ticks, a number with specified date-unit or specific numeric values for days, hours, minutes, seconds and milliseconds.

This function is NOT SQL compatible. For more information about SQL compatibility, see our [documentation](/platform/wemreference/sql-compatibility.md).
{% endhint %}

{% hint style="success" %}
Returns a <mark style="color:green;">**`Duration`**</mark> value compiled from the input values.

Returns <mark style="color:red;">**`Unknown`**</mark> if one of the parameter values is unknown or outside the common valid boundaries.
{% endhint %}

### Syntax

<details>

<summary><code>ToDuration(</code><mark style="color:blue;"><code>text</code></mark><code>)</code></summary>

`ToDuration(`"6.12:14:45"`)`\
\=>*Result: 6 days, 12 hours, 14 minutes and 45 seconds (mark the dot between day and hour)*

`ToDuration(`"12:14"`)`\
\=>*Result: 12 hours and 14 minutes*

`ToDuration("35:80:90")`\
\=>*Result: unknown*

</details>

<details>

<summary><code>ToDuration(</code><mark style="color:blue;"><code>ticks</code></mark><code>)</code></summary>

*There are 10 thousand ticks in one millisecond, 10 million ticks in one second, 600 million ticks in one minute.*

`ToDuration(650000000)`\
:thumbsup:*Result: 1 minute  and 5 seconds*

`ToDuration(50000000)`\
:thumbsup:*Result: 5 seconds*&#x20;

`ToDuration(unknownnumber)`\
:thumbsdown:*Result: unknown*

</details>

<details>

<summary><code>ToDuration(</code><mark style="color:blue;"><code>number</code></mark><code>, </code><mark style="color:blue;"><code>date_unit</code></mark><code>)</code></summary>

`ToDuration(6, day)`\
:thumbsup:*Result: 6 days*

`ToDuration(12, hour)`\
:thumbsup:*Result: 12 hours*

`ToDuration(14, minute)`\
:thumbsup:*Result: 14 minutes*

`ToDuration(45, second)`\
:thumbsup:*Result: 45 seconds*

`ToDuration(768, millisecond)`\
:thumbsup:*Result: 768 milliseconds*

</details>

<details>

<summary><code>ToDuration(</code><mark style="color:blue;"><code>day</code></mark><code>, </code><mark style="color:blue;"><code>hour</code></mark><code>, </code><mark style="color:blue;"><code>minute</code></mark><code>, </code><mark style="color:blue;"><code>second</code></mark><code>, </code><mark style="color:blue;"><code>millisecond</code></mark><code>)</code></summary>

`ToDuration(6, 12, 14, 45, 768)`\
:thumbsup:*Result: 6 days, 12 hours, 14 minutes, 45 seconds and 768 milliseconds*

`ToDuration( 0, 0, 14, 45, 0)`\
:thumbsup:*Result: 14 minutes and 45 seconds*

</details>

### Parameters

<table><thead><tr><th width="150">Name</th><th width="150">Type</th><th width="150" align="center">Required</th><th width="248.15953250810662">Description</th><th data-hidden>Required?</th></tr></thead><tbody><tr><td><mark style="color:blue;"><code>text</code></mark></td><td>text</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>text containing duration in dd.HH:mm:ss:fff form</td><td>yes</td></tr><tr><td><mark style="color:blue;"><code>ticks</code></mark></td><td>numeric</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>the number of ticks (tenthousandth of a millisecond)</td><td>yes</td></tr><tr><td><mark style="color:blue;"><code>number</code></mark></td><td>numeric</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>a numeric value to combine with the date_unit</td><td>yes</td></tr><tr><td><mark style="color:blue;"><code>date_unit</code></mark></td><td>keyword</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>one of the date_units: day, hour, minute, second, millisecond</td><td>no</td></tr><tr><td><mark style="color:blue;"><code>day</code></mark></td><td>numeric</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>the day unit (number of days)</td><td>no</td></tr><tr><td><mark style="color:blue;"><code>hour</code></mark></td><td>numeric</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>the hour unit (0 - 23)</td><td>no</td></tr><tr><td><mark style="color:blue;"><code>minute</code></mark></td><td>numeric</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>the minute unit (0 - 59)</td><td></td></tr><tr><td><mark style="color:blue;"><code>second</code></mark></td><td>numeric</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>the second unit (0 - 59)</td><td></td></tr><tr><td><mark style="color:blue;"><code>millisecond</code></mark></td><td>numeric</td><td align="center"><span data-gb-custom-inline data-tag="emoji" data-code="2611">☑️</span></td><td>the millisecond unit (0 - 999)</td><td></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wem.io/platform/wemreference/functions/date/toduration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
