Aswin Ram LatentView
Aswin Ram LatentView

Reputation: 21

Conversion of String to Date/Timestamp in Hive

I have a String value in the format "YYYY-MM-DD HH:MM:SS". I want to change the data type of this from string to Date/Time. I tried To_Date(),which gives me the date part of the string. Is there a function in hive which converts this string to Date/Time Stamp?

Upvotes: 2

Views: 3316

Answers (1)

Mukesh S
Mukesh S

Reputation: 2876

I am not sure which version of Hive you are using.

Check this link

it contains all the functions in Hive till Hive 0.13

In your case you should be looking at these functions:

1.) unix_timestamp(string date, string pattern)

2.) unix_timestamp(string date)

3.) from_unixtime(bigint unixtime[, string format])

Looking at your date format, you can use 1.) or 2.) of you need only timestamp(long value in Hive). Also if you need date in any specific format, you can use 3.) along with 1.) or 2.)

Hope it helps...!!!

Upvotes: 1

Related Questions