目录
- hive outline
- hive 日期函数
- 格式化时间函数:date_format
- 获取当前日期: current_date
- 获取当前时间戳: current_timestamp
- 获取当前UNIX时间戳函数: unix_timestamp
- UNIX时间戳转日期函数: from_unixtime(不指定时区)
- UNIX时间戳转换为日期函数: from_utc_timestamp(指定时区)
- 日期转UNIX时间戳函数: unix_timestamp
- 指定格式日期转UNIX时间戳函数: unix_timestamp
- 抽取日期函数: to_date
- 抽取日期:year month day hour minute second
- 日期转周函数: weekofyear
- 两日期相减函数: datediff
- 日期增加函数: date_add
- 日期减少函数: date_sub
hive outline
链接
hive 日期函数
格式化时间函数:date_format
格式化时间的前提是 xxxx-xx-xx,以-分割
处理xxxx/xx/xx格式的日期
把日期格式由2019/06/29替换为2019-06-29
获取当前日期: current_date
获取当前时间戳: current_timestamp
同一查询中对current_timestamp的所有调用均返回相同的值
获取当前UNIX时间戳函数: unix_timestamp
UNIX时间戳,是以的GMT/UTC时间(0时区)的【1970-01-01 T00:00:00】时刻为基准,到当前时刻所经过的秒数,与当前系统所处的时区无关,同一时刻在任何时区获取的时间戳都是一样的
UNIX时间戳转日期函数: from_unixtime(不指定时区)
UNIX时间戳,是以的GMT/UTC时间(0时区)的【1970-01-01 00:00:00】时刻为基准,到当前时刻所经过的秒数,与当前系统所处的时区无关,同一时刻在任何时区获取的时间戳都是一样的
UNIX时间戳转换为日期函数: from_utc_timestamp(指定时区)
UNIX时间戳,是以的GMT/UTC时间(0时区)的【1970-01-01 00:00:00】时刻为基准,到当前时刻所经过的秒数,与当前系统所处的时区无关,同一时刻在任何时区获取的时间戳都是一样的
以前
世界标准时间采用的是,格林威治标准时间(GMT)
现在
世界标准时间采用的是,协调世界时(UTC)
不管
是采用哪个标准下的时间,都
要表示出来中国属于哪个区,中国就属于东八区,+8表示东八区
日期转UNIX时间戳函数: unix_timestamp
指定格式日期转UNIX时间戳函数: unix_timestamp
抽取日期函数: to_date
抽取日期:year month day hour minute second
日期转周函数: weekofyear
两日期相减函数: datediff
语法:
日期格式要求’yyyy-MM-dd HH:mm:ss’ or ‘yyyy-MM-dd’
日期增加函数: date_add
日期减少函数: date_sub