hive时间函数

Hive时间函数from_utc_timestamp 把UTC标准时间切换到北京时间

让人想犯罪 __ 提交于 2020-01-11 00:08:31
首先简单地解释下几个含义: 1. 时间戳(unix timestamp) 表示以(1970-01-01 00:00:00)为起点,到现在的秒数。 2. GMT和UTC 先说结论,UTC与GMT基本上等同,误差不超过0.9秒。 GMT ,即格林尼治标准时间,也就是世界时。 UTC ,即协调世界时。UTC现在作为世界标准时间使用。 用from_utc_timestamp 把UTC标准时间切换到北京时间: --假如现在有UTC时间:'1970-01-01 00:00:00',把它转为北京时间,hiveSql如下: select from_utc_timestamp('1970-01-01 00:00:00','PRC') as bj_time >> 1970-01-01 08:00:00 其他常用的时间函数不在这里介绍了,这边传送门: 1. hive 时间戳函数之unix_timestamp,from_unixtime 2. 世界时区英文缩写一览表 Reference: https://www.cnblogs.com/xwdreamer/p/8761825.html 来源: CSDN 作者: geekingLi 链接: https://blog.csdn.net/m0_37773338/article/details/103930045

HIVE 时间操作函数

情到浓时终转凉″ 提交于 2019-12-22 15:33:21
日期函数UNIX时间戳转日期函数: from_unixtime语法: from_unixtime(bigint unixtime[, string format]) 返回值: string 说明: 转化UNIX时间戳(从1970-01-01 00:00:00 UTC到指定时间的秒数)到当前时区的时间格式 举例: hive> select from_unixtime(1323308943,’yyyyMMdd’) from dual; 20111208 获取当前UNIX时间戳函数: unix_timestamp语法: unix_timestamp() 返回值: bigint 说明: 获得当前时区的UNIX时间戳 举例: hive> select unix_timestamp() from dual; 1323309615 日期转UNIX时间戳函数: unix_timestamp语法: unix_timestamp(string date) 返回值: bigint 说明: 转换格式为“yyyy-MM-dd HH:mm:ss“的日期到UNIX时间戳。如果转化失败,则返回0。 举例: hive> select unix_timestamp(’2011-12-07 13:01:03′) from dual; 1323234063 指定格式日期转UNIX时间戳函数: unix

Hive常用系统函数-时间函数

霸气de小男生 提交于 2019-12-09 13:39:42
关于HIve常用的时间处理函数 函数 参数格式 内容 from_unixtime from_unixtime(bigint unixtime[, string format]) 将unix时间戳转换为当前所在时区的字符串时间,格式为"yyyy-MM-dd HH:mm:ss" unix_timestamp unix_timestamp() 以秒为单位获取当前的Unix时间戳。 unix_timestamp unix_timestamp(string date) 将格式为"yyyy-MM-dd HH:mm:ss"的字符串时间转换为Unix时间戳 unix_timestamp unix_timestamp(string date, string pattern) 将格式为pattern的字符串时间转换为Unix时间戳,若转换失败则返回0 to_date to_date(string timestamp) 传入字符串时间,返回"yyyy-MM-dd"日期 year year(string date) 返回给定字符串时间所在的年,例如:year(“1970-01-01 00:00:00”) = 1970; year(“1970-01-01”) = 1970 quarter quarter(date/timestamp/string) 返回给时间所在的季度,例如: year(“1970-04

hive 时间函数

匿名 (未验证) 提交于 2019-12-03 00:14:01
20190910 时间截断函数 trunc(string date, string format) 返回 string select trunc("2016-06-26","MM") --得到:2016-06-01 select trunc("2016-06-26","YY") --得到:2016-01-01 【注意】 format 所支持的格式为 MONTH/MON/MM, YEAR/YYYY/YY 【大写】 timestamp ת date 函数 to_date(string timestamp) 返回 string select to_date("1970-01-01 00:00:00") --得到:1970-01-01 时间格式转换 date_format(string date, string format) 返回 string select date_format('2015-04-08', 'y') --得到:2015 select date_format('2015-04-08', 'y-mm') --得到:2015-04 select date_format('2015-04-08', 'yy-mm') --得到:15-04 【注意】 format 所支持的格式为【大写或小写】 【注意】 hive版本是否支持 上面都是参考: Hive2.0 函数大全(中文版)

hive 时间函数

若如初见. 提交于 2019-12-01 09:40:52
hive 时间函数 20190910 时间截断函数 trunc(string date, string format) 返回 string select trunc("2016-06-26","MM") --得到:2016-06-01 select trunc("2016-06-26","YY") --得到:2016-01-01 【注意】 format 所支持的格式为 MONTH/MON/MM, YEAR/YYYY/YY 【大写】 timestamp 转 date 函数 to_date(string timestamp) 返回 string select to_date("1970-01-01 00:00:00") --得到:1970-01-01 时间格式转换 date_format(string date, string format) 返回 string select date_format('2015-04-08', 'y') --得到:2015 select date_format('2015-04-08', 'y-mm') --得到:2015-04 select date_format('2015-04-08', 'yy-mm') --得到:15-04 【注意】 format 所支持的格式为【大写或小写】 【注意】 hive版本是否支持 上面都是参考: Hive2.0

Hive 函数(六)

风流意气都作罢 提交于 2019-11-27 22:58:05
Hive函数 ​ Hive中提供了非常丰富的运算符和内置函数支撑,具体操作如下: 1.内置运算符 1.1关系运算符 运算符 类型 说明 A = B 所有原始类型 如果A与B相等,返回TRUE,否则返回FALSE A == B 无 失败,因为无效的语法。 SQL使用”=”,不使用”==”。 A <> B 所有原始类型 如果A不等于B返回TRUE,否则返回FALSE。如果A或B值为”NULL”,结果返回”NULL”。 A < B 所有原始类型 如果A小于B返回TRUE,否则返回FALSE。如果A或B值为”NULL”,结果返回”NULL”。 A <= B 所有原始类型 如果A小于等于B返回TRUE,否则返回FALSE。如果A或B值为”NULL”,结果返回”NULL”。 A > B 所有原始类型 如果A大于B返回TRUE,否则返回FALSE。如果A或B值为”NULL”,结果返回”NULL”。 A >= B 所有原始类型 如果A大于等于B返回TRUE,否则返回FALSE。如果A或B值为”NULL”,结果返回”NULL”。 A IS NULL 所有类型 如果A值为”NULL”,返回TRUE,否则返回FALSE A IS NOT NULL 所有类型 如果A值不为”NULL”,返回TRUE,否则返回FALSE A LIKE B 字符串 如 果A或B值为”NULL”,结果返回”NULL”