Ganesh
Ganesh

Reputation: 307

Convert string into date form

I have a column with string partition=201707070800, I need to convert this to 2017-07-08 , How can we achieve this is hive ?

Thanks

Upvotes: 0

Views: 148

Answers (1)

Shubham Srivastava
Shubham Srivastava

Reputation: 1877

Use substring function

select concat(substr(<column-string-date>,0,4),'-',substr(<column-string-date>,5,2),'-',substr(<column-string-date>,9,2)) from <table-name>;

this should give output like 2017-07-08

Upvotes: 1

Related Questions