Reputation: 201
I am having trouble casting a field from string to timestamp in hive after running date formats on it. The example of what I am trying to do is as follows:
select cast(date_format(from_unixtime(unix_timestamp(my_date ,'MM/dd/yyyy'), 'yyyy-MM-dd hh:mm:ss a'), 'MM/dd/yyyy hh:mm:ss a') as timestamp) my_date
from sample_schema.sample_table
The natural datatype this select statement results in is string and I need to be able to cast this to timestamp
Upvotes: 0
Views: 233
Reputation: 11090
If your my_date
is in "MM/dd/yyyy"
format.
select from_unixtime(unix_timestamp(my_date, "MM/dd/yyyy"),"MM/dd/yyyy hh:mm:ss a");
Upvotes: 1