hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Devopam Mittra <>
Subject Re: Date Functions in Hive
Date Tue, 23 Jun 2015 17:43:36 GMT
Please go through UDFs in detail :

I presume that your column is STRING datatype.

You may want to do the following:

SELECT CAST (to_date(from_unixtime(unix_timestamp(<date_col>, "MMM dd,
yyyy"))) AS DATE)
FROM <your_tablename>;

Once you have your DATE datatype conversion you may manipulate the output
to anything like MM-DD-YYYY as desired above (but I suggest you rethink why
it wouldn't be simply the default YYYY-MM-DD instead in native DATE
datatype itself)

If you have full month name like "January" , then you will have to use
MMMMM instead of MMM

If you are trying to do simply STRING manipulation to change the column
appearance I would rather suggest Unix / OS level file based manipulation

Apologies I haven't tested the code as I don't have access to my cluster

Hope it helps


On Tue, Jun 23, 2015 at 9:47 PM, saurabh <> wrote:

> Hi,
> Need some suggestions on Date function in Hive.
> The data appearing in the source file is in the format of "May 31, 2015".
> I want to convert the same in MM-DD-YYYY format.
> Please suggest if this can be done with existing Hive 14.0 functionality
> or it will require custom UDF.
> Please let me know if any more information is required on the same.
> Thanks,
> Saurabh

Devopam Mittra
Life and Relations are not binary

View raw message