ToDuration

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.

Returns a Duration value compiled from the input values.

Returns Unknown if one of the parameter values is unknown or outside the common valid boundaries.

Syntax

ToDuration(text)

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

ToDuration(ticks)

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

ToDuration(650000000) 👍Result: 1 minute and 5 seconds

ToDuration(50000000) 👍Result: 5 seconds

ToDuration(unknownnumber) 👎Result: unknown

ToDuration(number, date_unit)

ToDuration(6, day) 👍Result: 6 days

ToDuration(12, hour) 👍Result: 12 hours

ToDuration(14, minute) 👍Result: 14 minutes

ToDuration(45, second) 👍Result: 45 seconds

ToDuration(768, millisecond) 👍Result: 768 milliseconds

ToDuration(day, hour, minute, second, millisecond)

ToDuration(6, 12, 14, 45, 768) 👍Result: 6 days, 12 hours, 14 minutes, 45 seconds and 768 milliseconds

ToDuration( 0, 0, 14, 45, 0) 👍Result: 14 minutes and 45 seconds

Parameters

Name
Type
Required
Description

text

text

☑️

text containing duration in dd.HH:mm:ss:fff form

ticks

numeric

☑️

the number of ticks (tenthousandth of a millisecond)

number

numeric

☑️

a numeric value to combine with the date_unit

date_unit

keyword

☑️

one of the date_units: day, hour, minute, second, millisecond

day

numeric

☑️

the day unit (number of days)

hour

numeric

☑️

the hour unit (0 - 23)

minute

numeric

☑️

the minute unit (0 - 59)

second

numeric

☑️

the second unit (0 - 59)

millisecond

numeric

☑️

the millisecond unit (0 - 999)

Last updated