How do we get the current system date in Hive? In MySQL we have select now(), can any one please help me to get the query results. I am very new to Hive, is there a proper documentation for Hive that gives the details information about the pseudo columns, and built-in functions.
Hive provides few date functions to get the current timestamp values. The functions are current_timestamp() and unix_timestamp(). The format of the timestamp value is 'YYYY-MM-DD HH:MM:SS. sss'.
DATE values are represented in the form YYYY-MM-DD. Example: DATE '2014-12-07'. Date ranges allowed are 0000-01-01 to 9999-12-31. TIMESTAMP use the format yyyy-mm-dd hh:mm:ss[.
from_unixtime(,'yyyy-MM-dd') converts to a string of the given format, e.g. '2012-12-28' date_sub(,180) subtracts 180 days from that string, and returns a new string in the same format. unix_timestamp(,'yyyy-MM-dd') converts that string back to an int.
According to the LanguageManual, you can use unix_timestamp()
to get the "current time stamp using the default time zone." If you need to convert that to something more human-readable, you can use from_unixtime(unix_timestamp())
.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With