Month in MM using Month() in Hive
问题 Select * from concat(YEAR(DATE_SUB(MAX(Column_name),60),MONTH(DATE_SUB(MAX(Column_name),60),-01) The month() yields only single digit for months until September i.e Jan returns 1 instead of 01 . Need help in handling this. I am using this output to feed to another SELECT query using TO_DATE . 回答1: month() function returns integer, that is why there is no leading zero. You can use lpad(month,2,0) function to format month: hive> select lpad(month('2017-09-01'),2,0); OK 09 Time taken: 0.124