I have looked the entire forum for the solution without luck, so I believe its a fair question to ask and hope someone can help.

Very simply I have the following formula:

```
=2018 & "-" & A1
```

This returns text the following way eg:

```
2018-2
2018-1
2018-5
2018-10
2018-8
```

I am trying to sort these entries chronologically without success. I have tried the following: TEXT(B1,”YYYY-MM), DATEVALUE and custom formatting in cell options. All of them do not work.

Any ideas? Many thanks.

Try `="2018-" & TEXT(A1,"00")`

This will format the number in cell A1 as a 2-digit number, with leading zeros:

`| 1 → "01"|`

`| 2 → "02"|`

`| 10 → "10"|`

`| 34 → "34"|`

`|123 → "123"|`

So, you get `="2018-" & "01"`

, which is `="2018-01"`

Alternatively, you could use `=DATE(2018, A1, 1)`

to set it as a Date (1st of the month), and set the NumberFormat of your cell as `yyyy-mm`

Tags: date, excelexcel, text