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
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
Was this helpful?