The PI Data Type called Duration records spans of time from milliseconds through to hours. It is not a time PI for recording times of day such as noon, or 9:03am. It is designed for recording the length of time a phone call lasted, or F1 car lap times, and suchlike.
The database records all durations as the number of milliseconds.
The data can be entered manually into Browser or Classic in the usual way or imported using the PI import spreadsheet.
The data must be in a form which the system can recognise. We’ve tried to make the parser as lenient as possible. The following forms are accepted:
|10||A number by itself is assumed to be seconds|
|5 30||Two numbers without any other markers are assumed to be minutes and seconds, in this instance 5 minutes 30 seconds|
|3m45||Interpreted as 3 minutes and 45 seconds|
|1h||Interpreted as 1 hour|
|1h35m13s||Interpreted as 1 hour 35 minutes and twelve seconds|
|1 h 23 m||You can include spaces anywhere in the input strings|
|500ms||Milliseconds are identified with ms|
|12 40 15||Three numbers are assumed to be hours, minutes and seconds: 12h 40m 15s|
|1 2 3 4||Four numbers is equivalent to 1h 2m 3s 4ms|
|1h 30s||You can omit minutes: 1 hour and 30 seconds|
|99m||You can enter more minutes than there are in an hour. This will become 1h 39m|
|99m 99s||This will correct itself to 1h 40m 39s|
A negative duration is possible, even if you can’t measure them in the real world. Simply begin your input string with a minus symbol.
As with other PIs you can format duration data as you would like. The format string for a duration PI works a little differently to other format strings, since there are four number components of a duration PI: the hours, minutes, seconds and milliseconds. Each of these number components is represented by one of the following tokens.
|[hh]||Hours, with a leading zero|
|[h]||Hours without leading zeroes|
|[mm]||Minutes with leading zeroes|
|[m]||Minutes without leading zeroes|
|[ss]||Seconds with leading zeroes|
|[s]||Seconds without leading zeroes|
|[millis]||Milliseconds with two leading zeroes|
You can use these tokens alongside other text to style the output as you want. For instance, to show only seconds and milliseconds use [s]s [millis]ms
For hours and minutes only uses [h]h [mm]m or [h] hours [m] minutes for a longer variant.
[h] will show only the hours as a single number. Note that this will not display a decimal or fractional amount of time for the loss of precision of this format, nor will it round up or down. It will only display a 1 once the duration is longer than 1 hour, and a 2 once it is longer than two hours.
The default format, applied when the format field is empty is [h]h [mm]m [ss]s
You don’t have to enter a duration in terms of its format. If your format string if [h]h [m]m try typing 300000s into the text box to see what happens.
Durations cannot be longer than about one million hours. That’s 114 years, so it should be plenty enough for you!