1、北京时间格式   to   unix时间格式

数据格式:

2017-11-17 08:28:13

2017-11-17 08:28:10

2017-11-17 08:27:51.343

2017-11-17 08:27:48.021

presto单个标准时间转化(10位unix):

select to_unixtime(cast ('2017-08-30 10:36:15' as timestamp))

hive单个标准时间转化(10位unix):

select unix_timestamp(cast ('2017-08-30 10:36:15' as timestamp))

presto单个毫秒时间转化(13位unix):

select to_unixtime(cast ('2017-12-01 16:42:08.771' as timestamp))

hive单个毫秒时间转化(自动转为10位unix):

select unix_timestamp(cast ('2017-12-01 16:42:08.771' as timestamp))

presto变量转化(根据时间格式分别转化为10位unix、13位unix):

select to_unixtime(cast (time as timestamp))

from table1

hive变量转化(只能自动转化为10位unix):

select unix_timestamp(cast (time as timestamp))

from table1

where d = '2017-12-05'

2、unix时间格式   to  北京时间格式

数据格式:

1510894478

1510855235

1510855290929

1510873252377

presto单个10位unix(变为标准格式):

select format_datetime(from_unixtime(1510284058),'yyyy-MM-dd HH:mm:ss')

hive单个10位unix(变为标准格式):

select from_unixtime(1323308943123,'yyyy-MM-dd HH:mm:ss')

presto单个13位unix(毫秒格式):

select format_datetime(from_unixtime(1510284058.415),'yyyy-MM-dd HH:mm:ss.mmm')

hive单个13位unix(毫秒格式):手动截取10位

select from_unixtime(cast(substr(1323308943123,1,10) as int),'yyyy-MM-dd HH:mm:ss')

Presto  13、10位unix变量转化(只能截取成10位转化成标准格式):

select format_datetime(from_unixtime(cast(substr(ts,1,10) as double)),'yyyy-MM-dd HH:mm:ss')  from table1

hive变量转化(事先截取10位unix):

select from_unixtime(cast(substr(ts,1,10) as int),'yyyy-MM-dd HH:mm:ss')

from table1

where d = '2017-12-05'

最新文章

  1. iOS中多线程的实现方案
  2. xml schema xmlns xmlns:xsi xsi:schemaLocation targetnamespace
  3. linux @后面的主机名如何修改
  4. Winform水印
  5. Android中如何使用Intent在Activity之间传递对象[使用Serializable或者Parcelable]
  6. c# 基础(重写与覆盖:接口与抽象,虚函数与抽象函数)
  7. easyui提交表单数据的时候如何防止二次提交
  8. spring实战四之Bean的自动装配(注解方式)
  9. 使用C#创建计划任务(How to create a Task Scheduler use C# )
  10. java 吞吐量
  11. VS2010中更改项目名称(转载)
  12. 列"xx"不在表Table中
  13. HTML5学习笔记<一>: 认识H5
  14. adb deviecs时显示的emulator-5554如何删除
  15. Java数据结构和算法 - 什么是2-3-4树
  16. 想晋级高级工程师只知道表面是不够的!Git内部原理介绍
  17. 解决Docker安装MySQL不区分大小写问题
  18. 关于requestAnimationFrame与setInterval的一点差异
  19. 插槽slot
  20. linux audit审计(7)--读懂audit日志

热门文章

  1. Vue2.0---将页面中表格数据导出excel
  2. web 前端1 拾遗
  3. Vue 基础 day02
  4. javascript数组排序和prototype详解
  5. C++ Lambda 表达式使用详解
  6. 字典树(Trie树)实现与应用(转)
  7. 说明一下 os.path 和 sys.path 分别代表什么?
  8. MVC加深理解
  9. 2018-8-10-调试-ms-源代码
  10. 奇虎360的开源OpenResty Windows版本