简体   繁体   中英

How to convert Julian date to calendar date on Hive?

Is there any Hive function available to convert from Julian date to calendar date?

There are multiple types of Julian date. The Julian date I have takes 15001 for 2015-01-01 .

I couldn't find any relevant information on this page:

Hive Manual - Date Functions

 date_add('2015-01-01', juliadate - 15001)

Just wanted to add.

The below is for julian date format yyyyDDD

Input_julian_date : 2006121

substr(from_unixtime(unix_timestamp(cast(cast(Input_julian_date as int) as string),'yyyyDDD')),1,10) 

Output : 2006-05-01

Using "yyyyDDD" correctly converts Julian dates in Hive.

For example, I had a string column like "201707299999ABC" where the first 7 digits were the Julian date:

TO_DATE(FROM_UNIXTIME(UNIX_TIMESTAMP(SUBSTRING(my_julian_column, 0, 7), "yyyyDDD")))

Produces 2017-03-13 as expected.

Julian Date Format -- yyyyDDD The Date Format which is expected -- 'yyyy-MM-dd'

from_unixtime(unix_timestamp(cast(**julianl_date_col** as string),'yyyyDDD'),'yyyy-MM-dd') 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM