云日志服务 LTS-日期和时间函数:time_format函数

时间:2025-06-04 16:44:03

time_format函数

将毫秒级的时间戳或timestamp类型的日期和时间表达式expr,依据用户自定义的format参数以 Joda DateTimeFormat模式转换为指定日期和时间格式的字符串。

语法:time_format(expr, format)

表36 参数说明

参数名称

描述

类型

是否必选

expr

timestamp类型的日期和时间表达式或毫秒级的时间戳

timestamp或Long

format

时间格式。

String

返回值类型:String类型

示例:SELECT TIME_FORMAT(__time, 'yyyy-MM-dd HH:mm:ss'), TIME_FORMAT(from_unixtime(__time), 'yyyy-MM-dd HH:mm:ss')

表37 查询分析结果

类型

场景1

场景2

查询语句

TIME_FORMAT(__time, 'yyyy-MM-dd HH:mm:ss')

TIME_FORMAT(from_unixtime(__time), 'yyyy-MM-dd HH:mm:ss')

返回结果

2024-11-18 22:15:16

2024-11-18 22:15:16

support.huaweicloud.com/usermanual-lts/lts_07_0206.html
提示

您即将访问非华为云网站,请注意账号财产安全