– 计算每月最后一天
select last_day(‘2020-04-02’) ==> 2020-04-30
– 替换字符
select regexp_replace(‘2020-04-02’,‘-’,‘’) ==> 20200402
– 计算月份差值
select months_between(‘2020-04-02’,‘2019-04-02’) ==> 12.0
– 根据月份获取该月最后一天
select regexp_replace(last_day(from_unixtime(unix_timestamp(concat(202004),‘yyyyMM’))),‘-’,‘’)
– 获取前一天
select from_unixtime(unix_timestamp(date_sub(from_unixtime(unix_timestamp(‘20200402’,‘yyyyMMdd’),‘yyyy-MM-dd’),1),‘yyyy-MM-dd’),‘yyyyMMdd’) ==> 20200401