Hive Current date function

banditKing picture banditKing · Mar 21, 2016 · Viewed 7.9k times · Source

I want to get the current date in beeline.

I tried to use this:

FROM_UNIXTIME(UNIX_TIMESTAMP())

it outputs this:

16-03-21

What I was looking to get it:

2016-03-21 09:34

How do I do it? I see the beeline documentation here: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DateFunctions

But it didnt work for me.

Answer

VasanthKarthik picture VasanthKarthik · Mar 22, 2016

you can get it by passing expected format as a parameter of from_unixtime function.

Example :

select from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:MM');

Result:

2016-03-21 16:03