返回 当前时间
MySQL use now()
Hive use
from_unixtime(unix_timestamp(),'yyyy-MM-dd')
from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss')
--示例:
SELECT from_unixtime(unix_timestamp(),'yyyy-MM-dd') 2018-11-05
SELECT from_unixtime(unix_timestamp(),'yyyyMMdd') 20181105
释义:unix_timestamp()
返回当前时区的unix时间戳from_unixtime(bigint unixtime[,string format])
时间戳转日期函数to_date(string date)
YEAR()
MONTH()
DAY()
weekofyear()
本年多少周
日期差
datediff(enddate,begindate)
date\_add(date,days)
date+daysdate\_sub(date,days)
date-days
小时差
SELECT
(hour(from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss'))-hour('2018-01-01 12:00:00')+
(datediff(from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss'),'2018-01-01 12:00:00'))*24) as hour_dValue