Using TimeSpan Functions
These functions are for creating instances of TimeSpan and extracting values from them.
FROMDAYS
Returns a TimeSpan value from a Double expression that represents a number of days, either integral or fractional.
Examples:
SELECT fromdays(1) -- returns 1.00:00:00
SELECT fromdays(1.5) -- returns 1.12:00:00
FROMHOURS
Returns a TimeSpan value from a Double expression that represents a number of hours, either integral or fractional.
Examples:
SELECT fromhours(1) -- returns 01:00:00
SELECT fromhours(1.5) -- returns 01:30:00
FROMMILLISECONDS
Returns a TimeSpan value from a Double expression that represents a number of milliseconds, either integral or fractional.
Examples:
SELECT frommilliseconds(1) -- returns 00:00:00.0010000
SELECT frommilliseconds(1.5) -- returns 00:00:00.0015000
FROMMINUTES
Returns a TimeSpan value from a Double expression that represents a number of minutes, either integral or fractional.
Examples:
SELECT fromminutes(1) -- returns 00:01:00
SELECT fromminutes(1.5) -- returns 00:01:30
FROMSECONDS
Returns a TimeSpan value from a Double expression that represents a number of seconds, either integral or fractional.
Examples:
SELECT fromseconds(1) -- returns 00:00:01
SELECT fromseconds(1.5) -- returns 00:00:01.5000000
TOTALDAYS
Returns a Double value representing the total number of days in a TimeSpan expression.
Examples:
SELECT totaldays('1.00:00:00') --returns 1
SELECT totaldays('1.12:00:00') --returns 1.5
TOTALHOURS
Returns a Double value representing the total number of hours in a TimeSpan expression.
Examples:
SELECT totalhours('01:00:00') --returns 1
SELECT totalhours('01:30:00') --returns 1.5
TOTALMILLISECONDS
Returns a Double value representing the total number of milliseconds in a TimeSpan expression.
Examples:
SELECT totalmilliseconds('00:00:01') --returns 1000
SELECT totalmilliseconds('00:00:00.0015') --returns 1.5
TOTALMINUTES
Returns a Double value representing the total number of minutes in a TimeSpan expression.
Examples:
SELECT totalminutes('00:01:00') --returns 1
SELECT totalminutes('00:01:30') --returns 1.5
TOTALSECONDS
Returns a Double value representing the total number of seconds in a TimeSpan expression.
Examples:
SELECT totalseconds('00:00:01') --returns 1
SELECT totalseconds('00:00:01.500') --returns 1.5