0

I have a table that looks like:

ID   start_time     end_time     username
1    1451674800     1451692800   blah

And I want a table that looks like:

ID   username   hours
1    blah       [11, 12, 13, 14, 15, 16]

Where [11, 12, 13, 14, 15, 16] is an array with values corresponding to the hours (PST) which lie between 1451674800 and 1451692800 (UNIX time).

My thought is that I need to use Hive's timestamp functions, but I am so incredibly unfamiliar with Hive and especially with the timestamp functions that I don't even know where to begin.

Danny David Leybzon
  • 670
  • 1
  • 9
  • 21

1 Answers1

1

First create function which convert UNIX time to ordinal time. Can take from here

Then calculate DATEDIFF(hh,start_time,end_time). Add this number of hours begining from DATEPART(dd,start_time) and concatenate them.

Community
  • 1
  • 1
tungula
  • 578
  • 1
  • 6
  • 12