how to convert date 2017-sep-12 To 2017-09-12 in HIVE

前端 未结 1 1383
日久生厌
日久生厌 2020-12-21 11:42

I am facing one issue in converting the date in hive. I need to convert 2017-sep-12 To 2017-09-12 . How can i achieve this in HIVE

相关标签:
1条回答
  • 2020-12-21 12:33

    Use unix_timestamp(string date, string pattern) to convert given date format to seconds passed from 1970-01-01. Then use from_unixtime() to convert to given format:

    hive> select from_unixtime(unix_timestamp('2017-sep-12' ,'yyyy-MMM-dd'), 'dd-MM-yyyy');
    OK
    12-09-2017
    
    0 讨论(0)
提交回复
热议问题