Home / Search/ Language Reference/ Functions/ Scalar Functions/ DateTime Functions/format_timespan

format_timespan

The format_timespan function formats a timespan according to the provided format.

Syntax

    format_timespan( Timespan, Format)

Arguments

  • Timespan: A timespan.
  • Format: Format specifier string, consisting of one or more format elements.

Returns

The string with the format result.

Supported Formats

Format specifierDescriptionExamples
d-ddddddddThe number of whole days in the time interval. Padded with zeros if needed.15.13:45:30: d -> 15, dd -> 15, ddd -> 015
fThe tenths of a second in the time interval.15.13:45:30.6170000 -> 6, 15.13:45:30.05 -> 0
ffThe hundredths of a second in the time interval.15.13:45:30.6170000 -> 61, 15.13:45:30.0050000 -> 00
fffThe milliseconds in the time interval.6/15/2009 13:45:30.617 -> 617, 6/15/2009 13:45:30.0005 -> 000
ffffThe ten thousandths of a second in the time interval.15.13:45:30.6175000 -> 6175, 15.13:45:30.0000500 -> 0000
fffffThe hundred thousandths of a second in the time interval.15.13:45:30.6175400 -> 61754, 15.13:45:30.000005 -> 00000
ffffffThe millionths of a second in the time interval.15.13:45:30.6175420 -> 617542, 15.13:45:30.0000005 -> 000000
fffffffThe ten millionths of a second in the time interval.15.13:45:30.6175425 -> 6175425, 15.13:45:30.0001150 -> 0001150
FIf non-zero, the tenths of a second in the time interval.15.13:45:30.6170000 -> 6, 15.13:45:30.0500000 -> (no output)
FFIf non-zero, the hundredths of a second in the time interval.15.13:45:30.6170000 -> 61, 15.13:45:30.0050000 -> (no output)
FFFIf non-zero, the milliseconds in the time interval.15.13:45:30.6170000 -> 617, 15.13:45:30.0005000 -> (no output)
FFFFIf non-zero, the ten thousandths of a second in the time interval.15.13:45:30.5275000 -> 5275, 15.13:45:30.0000500 -> (no output)
FFFFFIf non-zero, the hundred thousandths of a second in the time interval.15.13:45:30.6175400 -> 61754, 15.13:45:30.0000050 -> (no output)
FFFFFFIf non-zero, the millionths of a second in the time interval.15.13:45:30.6175420 -> 617542, 15.13:45:30.0000005 -> (no output)
FFFFFFFIf non-zero, the ten millionths of a second in the time interval.15.13:45:30.6175425 -> 6175425, 15.13:45:30.0001150 -> 000115
HThe hour, using a 24-hour clock from 0 to 23.15.01:45:30 -> 1, 15.13:45:30 -> 13
HHThe hour, using a 24-hour clock from 00 to 23.15.01:45:30 -> 01, 15.13:45:30 -> 13
mThe number of whole minutes in the time interval that are not included as part of hours or days. Single-digit minutes do not have a leading zero.15.01:09:30 -> 9, 15.13:29:30 -> 29
mmThe number of whole minutes in the time interval that are not included as part of hours or days. Single-digit minutes have a leading zero.15.01:09:30 -> 09, 15.01:45:30 -> 45
sThe number of whole seconds in the time interval that are not included as part of hours, days, or minutes. Single-digit seconds do not have a leading zero.15.13:45:09 -> 9
ssThe number of whole seconds in the time interval that are not included as part of hours, days, or minutes. Single-digit seconds have a leading zero.15.13:45:09 -> 09

Supported Delimiters

Format specifier can include following delimiter characters:

DelimiterComment
 Space
/
-Dash
:
,
.
\_
[
]

Examples

Let t = time(29.09:00:05.12345) in the following examples:

  • v1=format_timespan(t, 'dd.hh:mm:ss:FF') returns as 29.09:00:05:12
  • v2=format_timespan(t, 'ddd.h:mm:ss [fffffff]') returns as 029.9:00:05 [1234500]