Search code examples
hadoophivehiveqlhadoop-partitioning

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


Solution

  • 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