timespan 数据类型The timespan data type

timespan (time) 数据类型表示时间间隔。The timespan (time) data type represents a time interval.

timespan 文本timespan literals

timespan 类型的文本采用语法为 timespan(value),其中的 value 支持多种格式,如下表所示:Literals of type timespan have the syntax timespan(value), where a number of formats are supported for value, as indicated by the following table:

ValueValue 时间长度Length of time
2d 2 天2 days
1.5h 1.5 小时1.5 hour
30m 30 分钟30 minutes
10s 10 秒10 seconds
0.1s 0.1 秒0.1 second
100ms 100 毫秒100 millisecond
10microsecond 10 微秒10 microseconds
1tick 100 纳秒100ns
time(15 seconds) 15 秒15 seconds
time(2) 2 天2 days
time(0.12:34:56.7) 0d+12h+34m+56.7s

特殊形式 time(null)null 值The special form time(null) is the null value.

timespan 运算符timespan operators

两个 timespan 类型的值可以相加、相减和相除。Two values of type timespan may be added, subtracted, and divided. 最后一个操作返回一个 real 类型的值,表示一个值可以是另一个值的小数倍。The last operation returns a value of type real representing the fractional number of times one value can fit the other.


下面的示例以多种方式计算一天中的秒数:The following example calculates how many seconds are in a day in several ways:

    result1 = 1d / 1s,
    result2 = time(1d) / time(1s),
    result3 = 24 * 60 * time(00:01:00) / time(1s)