日期函数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_timestamp语法:   unix_timestamp(string date, string pattern)

返回值:   bigint

说明: 转换pattern格式的日期到UNIX时间戳。如果转化失败,则返回0。

举例:

hive>   select unix_timestamp(’20111207 13:01:03′,’yyyyMMdd HH:mm:ss’) from dual;

1323234063

日期时间转日期函数: to_date语法:   to_date(string timestamp)

返回值:   string

说明: 返回日期时间字段中的日期部分。

举例:

hive>   select to_date(’2011-12-08 10:03:01′) from dual;

2011-12-08

日期转年函数: year语法:   year(string date)

返回值: int

说明: 返回日期中的年。

举例:

hive>   select year(’2011-12-08 10:03:01′) from dual;

2011

hive>   select year(’2012-12-08′) from dual;

2012

日期转月函数: month语法: month   (string date)

返回值: int

说明: 返回日期中的月份。

举例:

hive>   select month(’2011-12-08 10:03:01′) from dual;

12

hive>   select month(’2011-08-08′) from dual;

8

日期转天函数: day语法: day   (string date)

返回值: int

说明: 返回日期中的天。

举例:

hive>   select day(’2011-12-08 10:03:01′) from dual;

8

hive>   select day(’2011-12-24′) from dual;

24

日期转小时函数: hour语法: hour   (string date)

返回值: int

说明: 返回日期中的小时。

举例:

hive>   select hour(’2011-12-08 10:03:01′) from dual;

10

日期转分钟函数: minute语法: minute   (string date)

返回值: int

说明: 返回日期中的分钟。

举例:

hive>   select minute(’2011-12-08 10:03:01′) from dual;

3

日期转秒函数: second语法: second   (string date)

返回值: int

说明: 返回日期中的秒。

举例:

hive>   select second(’2011-12-08 10:03:01′) from dual;

1

日期转周函数: weekofyear语法:   weekofyear (string date)

返回值: int

说明: 返回日期在当前的周数。

举例:

hive>   select weekofyear(’2011-12-08 10:03:01′) from dual;

49

日期比较函数: datediff语法:   datediff(string enddate, string startdate)

返回值: int

说明: 返回结束日期减去开始日期的天数。

举例:

hive>   select datediff(’2012-12-08′,’2012-05-09′) from dual;

213

日期增加函数: date_add语法:   date_add(string startdate, int days)

返回值: string

说明: 返回开始日期startdate增加days天后的日期。

举例:

hive>   select date_add(’2012-12-08′,10) from dual;

2012-12-18

日期减少函数: date_sub语法:   date_sub (string startdate, int days)

返回值: string

说明: 返回开始日期startdate减少days天后的日期。

举例:

hive>   select date_sub(’2012-12-08′,10) from dual;

2012-11-28

hive中常用的时间处理函数相关推荐

  1. hive获取月份_【Hive】Hive中常用日期函数整理

    前言 使用hive进行时间处理的过程中,有时忘记一些常用的函数用法,现整理一下hive中常用日期函数,当做备忘录使用,忘记来翻阅一下. 1 时间戳转化日期函数 时间戳必须是10位,默认情况下转化为'y ...

  2. MySQL中常用日期时间函数及获得

    MySQL中常用日期时间函数: 下面的查询选择了所有记录,其date_col的值是在最后30天以内: mysql> SELECT something FROM table WHERE TO_DA ...

  3. hive中常用字符串转时间的处理方法

    数据 2018-11-01 07:57:33 1.使用hive内置的时间日期函数完成数据ETL. select to_date(time_local) as daystr,date_format(ti ...

  4. Mysql中当前日期(时间)函数总结

    Mysql中当前日期(时间)函数总结 select now():获取当前日期(包含时分秒) 2.Select date_formate(now(),"格式化") select da ...

  5. Python中常用的高阶函数

    Python 中常用的高阶函数 ① filter(function,iterable)filter(function, iterable)filter(function,iterable)   过滤器 ...

  6. hive(3)——在hive中使用自己写的函数(python实现)

    如果我们想在hive中添加自己写的函数,可用如下方法: 前提:已经开启hdfs,yarn服务,并且关闭safe模式,打开mysql ps:udf是mapper类型的,进来一个数据,出去一个数据 (1) ...

  7. mysql中常用的时间工具

    本文记录下mysql中常用的时间工具 文章目录 概述 概述 sql文件 #查询现在的时间 SELECT now() now#格式化时间为时分秒 SELECT DATE_FORMAT(now(), '% ...

  8. python数据处理常用函数_Python中常用操作字符串的函数与方法总结

    Python中常用操作字符串的函数与方法总结 这篇文章主要介绍了Python中常用操作字符串的函数与方法总结,包括字符串的格式化输出与拼接等基础知识,需要的朋友可以参考下 例如这样一个字符串 Pyth ...

  9. VBA中常用的字符串处理函数

    在VBA中处理字符串 分类:ExcelVBA>>常用函数 目录 1 VBA中的字符串 2 VBA中处理字符串的函数 2.1 比较字符串 2.2 转换字符串 2.3 创建字符串 2.4 获取 ...

最新文章

  1. 使字符串的首字母大写(具有最佳性能)
  2. python爬虫应用实战-如何爬取好看的小姐姐照片?
  3. AccountManagment
  4. CRM_OPPORT_TEXT_DETER_STANDARD
  5. Linux命令与shell
  6. 学习Scala:使用try-catch表达式处理异常
  7. YUV采样及存储格式
  8. 安装node.js、webpack、vue 和vue-cli 以及安装速度慢/不成功的解决方法
  9. Wordpress在主题中自定义登陆页面并且禁用自带的登陆页面
  10. tensorflow中tfrecords使用介绍
  11. c54x汇编语言程序设计,第5章 apos;C54x汇编语言程序设计.doc
  12. 兰亭字体linux版本,两种方法,让最新版 Windows 10 的字体更「养眼」
  13. python+iOS自动化环境搭建
  14. wordpress设置首页为特定页
  15. grafana绘图配置查询变量+多级变量联动
  16. 【一】生成CA根证书、公钥、私钥指令(数字证书)
  17. linux 触摸屏驱动分析
  18. 【技巧】去掉RedisDesktopManager更新提示弹窗
  19. .bat输出目录下所有文件的绝对路径
  20. 仇家结亲优酷土豆闪婚内幕

热门文章

  1. tcp/ip协议概述(8)----TCP/IP加速原理详解
  2. maya对象属性_Maya创建、编辑或删除自定义属性,MAYA
  3. 基于STM32F1自写移植代码分享系列之0.96寸OLED模块
  4. 当尚科在“春光里” ——中国产投大会在京圆满举行
  5. B. Kind Anton_牛哄哄的柯南
  6. 飞桨社区项目PaddleMM正式进入木兰开源社区进行孵化
  7. linux 4k对齐设置步骤,linux查看硬盘4K对齐方法
  8. 028 写给常光顾俺博客的朋友
  9. strictmode android,Android 应用性能优化-StrictMode(严格模式)
  10. CSDN博客编辑用html记录