0

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

Pang
  • 9,564
  • 146
  • 81
  • 122
Osiris
  • 1,007
  • 4
  • 17
  • 30

4 Answers4

0
 date_add('2015-01-01', juliadate - 15001)
Osiris
  • 1,007
  • 4
  • 17
  • 30
0

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

gre_gor
  • 6,669
  • 9
  • 47
  • 52
0

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.

Nic Scozzaro
  • 6,651
  • 3
  • 42
  • 46
0

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') 
Hiten004
  • 2,425
  • 1
  • 22
  • 34
Ankita
  • 1