Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Applies to:
Databricks SQL
Databricks Runtime 18.3 and above
Returns time truncated to the unit specified in unit.
Syntax
time_trunc(unit, expr)
Arguments
unit: A STRING literal.expr: A TIME expression.
Returns
A TIME.
Valid units for unit are (case-insensitive):
'HOUR': Zero out the minute, second, and fraction parts.'MINUTE': Zero out the second and fraction parts.'SECOND': Zero out the fractional second part.'MILLISECOND': Zero out sub-millisecond fractions.'MICROSECOND': TIME values are stored at microsecond precision, so no sub-microsecond fractions exist to zero out. The value is unchanged.
Examples
> SELECT time_trunc('HOUR', TIME'13:08:15.123');
13:00:00
> SELECT time_trunc('MINUTE', TIME'13:08:15.123');
13:08:00
> SELECT time_trunc('SECOND', TIME'13:08:15.123456');
13:08:15
> SELECT time_trunc('MILLISECOND', TIME'13:08:15.123456');
13:08:15.123000