- 显示当前日期
select current_date
- hive上当前日期转成presto上的timestamp
select DATE_PARSE(cast(CURRENT_DATE as VARCHAR),'%Y-%m-%d')
- 精确到毫秒,并显示时区
select now()
- 显示前一天
select current_date - interval '1' day
- 字符串转时间
select date_parse('20210512','%Y%m%d')
- 时间转字符串
select date_format(current_date -interval '1' day,'%Y-%m-%d %T')
- 计算时间的函数
date_add(unit,value,timestamp)
其中unit为单位,可使用的有’day’,‘week’,'month’等等;value是偏移量,正数表示计算未来的时间,负数则是历史时间;
例:select date_add(‘week’,10,current_date) 显示 2021-10-14 select date_add(‘month’,-