string
from_unixtime(unix_timestamp('2020-08-25 23:15:25','yyyy-MM-dd HH:mm:ss'),'yyyyMMdd')
20200825
字符串格式转换
string
from_unixtime(unix_timestamp('2020-08-25 23:15:25','yyyy-MM-dd HH:mm:ss'),'yyyyMMddHHmmss')
20200825231525
字符串格式转换
cast('2020-08-25' as date)
2020-08-25
字符串转日期
string
date_format('2020-08-25 11:15:25','yyyyMMddHHmmss')
20200825111525
字符串日期格式转换
string
date_format('2020-08-25','yyyyMMdd')
20200825
字符串日期格式转换
string
date_format('2020-08-25','yyyy')
字符串日期格式提取年份
string
date_format('2020-08-25','MM')
字符串日期格式提取月份
string
date_format('2020-08-25','dd')
字符串日期格式提取天
datediff('2020-08-25','2020-08-20')
日期想减得到相差天数
datediff('2020-08-25 11:00:00','2020-08-21 09:00:00')
日期想减得到相差天数并忽略日期的其他部分
current_date()
yyyy-MM-dd格式的当前日期部分
获取当前系统日期部分
timestamp
current_timestamp()
yyyy-MM-dd HH:mm:ss.ff例如2020-08-25 20:33:20.38格式的当前时间
获取系统当前时间
bigint
unix_timestamp('2020-08-25 11:30:01')
1598326201
将 yyyy-MM-dd HH:mm:ss格式的字符串转换为Unix 时间戳 (秒)