impala内置时间函数

获取当前时间戳函数
current_timestamp() 2021-02-04 08:46:27
now() 2021-02-04 08:46:27
unix_timestamp() 1612399587
timeofday() Thu Feb 04 08:46:27 2021 CST
utc_timestamp() 2021-02-04 00:46:27
时间计算函数
now() <=> 2021-02-04 08:46:27
years_add(now(),1) 2022-02-04 08:46:27
years_sub(now(),1) 2020-02-04 08:46:27
months_add(now(),1) 2021-03-04 08:46:27
months_sub(now(),1) 2021-01-04 08:46:27
add_months(now(),1) 2021-03-04 08:46:27
weeks_add(now(), 1) 2021-02-11 08:46:27
weeks_sub(now(), 1) 2021-01-28 08:46:27
days_add(now(),1) 2021-02-05 08:46:27
days_sub(now(), 1) 2021-02-03 08:46:27
date_add(now(), 1) 2021-02-05 08:46:27
date_sub(now(), 1) 2021-02-03 08:46:27
adddate(now(),1) 2021-02-05 08:46:27
subdate(now(),1) 2021-02-03 08:46:27
hours_add(now(),1) 2021-02-03 09:46:27
hours_sub(now(),1) 2021-02-03 07:46:27
minutes_add(now(),1) 2021-02-03 08:47:27
minutes_sub(now(),1) 2021-02-03 08:45:27
seconds_add(now(),1) 2021-02-04 08:46:28
seconds_sub(now(),1) 2021-02-04 08:46:26
milliseconds_add(now(),1000) 2021-02-04 08:46:28.707274000
milliseconds_sub(now(),1000) 2021-02-04 08:46:26.707274000
microseconds_add(now(),1000) 2021-02-04 08:46:27.708274000
microseconds_sub(now(),1000) 2021-02-04 08:46:27.706274000
nanoseconds_add(now(),1000) 2021-02-04 08:46:27.707275000
nanoseconds_sub(now(),1000) 2021-02-04 08:46:27.707273000
date_add(now(),interval 2 months) 2021-04-04 08:46:27
date_sub(now(),interval 2 hours) 2021-02-04 06:46:27
获取时间指定单位
now() <=> 2021-02-04 08:46:27
year(now()) 2021
quarter(now()) 1
month(now()) 2
monthname(now()) February
week(now()) 5
weekofyear(now()) 5
dayofweek(now()) 5
dayname(now()) Thursday
next_day(now(),‘monday’) 2021-02-08 08:46:27
day(now()) 4
dayofmonth(now()) 4
last_day(now()) 2021-02-28 00:00:00
dayofyear(now()) 35
hour(now()) 8
minute(now()) 46
second(now()) 27
millisecond (now()) 707
extract(now(),‘year’) 2021
extract(year from now()) 2021
trunc(now(),‘year’) 2021-01-01 00:00:00
date_trunc(‘year’,now()) 2021-01-01 00:00:00
时间比较函数
datediff(‘2020-07-31’, ‘2020-07-30’) 1
int_months_between(‘2020-03-31’, ‘2020-01-20’) 2
months_between(‘2020-02-28’,‘2020-03-01’) -0.12903225806451613
date_cmp(‘2021-01-01’,‘2020-12-01’) 1
timestamp_cmp(‘2021-01-01’,‘2020-12-01’) 1
时间格式转换函数
to_date(now()) 2021-02-04
to_timestamp(1612399587) 2021-02-04 08:46:27
to_timestamp(‘2021/02/04’,‘yyyy/MM/dd’) 2021-02-04 00:00:00
to_utc_timestamp(now(),‘Asia/Shanghai’) 2021-02-04 00:46:27
from_timestamp(now(),‘yyyy/MM’) 2021/02
from_timestamp(‘2021-02-04’,‘yyyy/MM’) 2021/02
from_unixtime(1612399587) 2021-02-04 08:46:27
from_unixtime(1612399587,‘yyyy/MM’) 2021/02
from_utc_timestamp(now(),‘Asia/Shanghai’) 2021-02-04 16:46:27
unix_timestamp(‘2021-02-04’) 1612368000
unix_timestamp(now()) 1612399587
unix_timestamp(‘2021-02-04 08:46:27-01:00’, 1612403187 (相当于2021-02-04 09:46:27)

你可能感兴趣的:(impala日期函数,数据库)