如何在 HIVE 中将日期 2017-sep-12 转换为 2017-09-12 [英] how to convert date 2017-sep-12 To 2017-09-12 in HIVE

查看:42
本文介绍了如何在 HIVE 中将日期 2017-sep-12 转换为 2017-09-12的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在转换 hive 中的日期时遇到了一个问题.我需要将 2017-sep-12 转换为 2017-09-12 .我怎样才能在 HIVE 中实现这一点

I am facing one issue in converting the date in hive. I need to convert 2017-sep-12 To 2017-09-12 . How can i achieve this in HIVE

推荐答案

使用 unix_timestamp(string date, string pattern) 将给定的日期格式转换为从 1970-01-01 过去的秒数.然后使用 from_unixtime() 转换为给定的格式:

Use unix_timestamp(string date, string pattern) to convert given date format to seconds passed from 1970-01-01. Then use from_unixtime() to convert to given format:

hive> select from_unixtime(unix_timestamp('2017-sep-12' ,'yyyy-MMM-dd'), 'dd-MM-yyyy');
OK
12-09-2017

这篇关于如何在 HIVE 中将日期 2017-sep-12 转换为 2017-09-12的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆