Suvarna Pattayil
Suvarna Pattayil

Reputation: 5239

display date only once [elegant way] in Hive

How do I display the date only once using the inbuilt Date and Time functions

In mysql we can do select curdate(); to get

+------------+
| curdate()  |
+------------+
| 2013-07-23 |
+------------+

Trying select unixtime(); in Hive gives me FAILED: ParseException line 1:17 mismatched input '<EOF>' expecting FROM near ')' in from clause

Doing , select from_unixtime(unix_timestamp(),"yyyy-MM-hh") from abc.xyz LIMIT 1; gives me

OK
2013-07-03

my expected output but it doesn't seem really sensible to me to use a random database and its table just for accessing the date. What is the proper way of doing this?

Upvotes: 0

Views: 180

Answers (2)

Lukas Vermeer
Lukas Vermeer

Reputation: 5940

Currently, Hive does not support constructing rows without reading any other tables (which is what you are trying to do when you run select curdate() or select curdate() from dual).

This is work in progress.

Upvotes: 1

dimamah
dimamah

Reputation: 2903

use unix_timestamp()
For other date functions look here

Upvotes: 1

Related Questions