Google-sheets – Google Sheets: Displaying month with leading zero in array formula

google sheets

My current array formula is =ARRAYFORMULA(IF(A8:A <> ""; YEAR(A8:A) & "/" & MONTH(A8:A); ""))

which turns "16 january 2016" etc. into "2016/1"

However when I later pull them elsewhere they're in the wrong order:
2017/1
2017/11
2017/2

This is because months are showing as '1' instead of '01'. How can this be remedied?

Example sheet

Best Answer

Use TEXT function to format the month column. Your array formula would change to:

=ARRAYFORMULA(IF(A8:A <> ""; YEAR(A8:A) & "/" & TEXT(MONTH(A8:A);"00"); ""))