Hive 从 Greenplum SQL 迁移日期格式
我正在寻求帮助将下面的 sql 查询转换为 hive 支持的日期格式。请协助。
GP:SQL
select to_date('19800302000000','yyyymmddhh24miss') date_of_birth
GP 输出:1980-03-02
GP 查询:
extract(year from age(current_date-1, to_date(b.birthday,'yyyymmddhh24miss'))) age
我们在 hive 中寻找类似的内容。请帮助我们。
I am looking for help to convert below sql query into hive supported date format. kindly assist.
GP: SQL
select to_date('19800302000000','yyyymmddhh24miss') date_of_birth
GP Output : 1980-03-02
GP query :
extract(year from age(current_date-1, to_date(b.birthday,'yyyymmddhh24miss'))) age
we are looking similar out in hive. please help us.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于
select to_date('19800302000000','yyyymmddhh24miss')
使用此选择 from_unixtime(unix_timestamp('19800302000000','yyyyMMddhhmmSS'))
。如果您不需要时间部分,请使用此
选择 to_date(from_unixtime(unix_timestamp('19800302000000','yyyyMMddhhmmSS')))
。对于
extract(year from age(current_date-1, to_date(b.birthday,'yyyymmddhh24miss')))age
使用以下代码。它应该给出昨天和出生日期之间的年份差异。
For
select to_date('19800302000000','yyyymmddhh24miss')
use thisselect from_unixtime(unix_timestamp('19800302000000','yyyyMMddhhmmSS'))
.If you dont want time part, use this
select to_date(from_unixtime(unix_timestamp('19800302000000','yyyyMMddhhmmSS')))
.For
extract(year from age(current_date-1, to_date(b.birthday,'yyyymmddhh24miss'))) age
use below code. it should give difference of years between yesterday and DOB.