Question: I have many `varchar` YYYY-mm values in my table : 

[![enter image description here](https://i.stack.imgur.com/OhtND.png)](https://i.stack.imgur.com/OhtND.png)

But now I need days in Month from this. 

> 
> I need the result: 2018-04 -> 30 Days
> 
> 
> 

So how I can achieve this?

I thank you in advance!

Answer: 
In addition to Gordon's spot-on answer, here is another way to compute the number of days in the month:

```
SELECT
    DATEDIFF(day,
             TRY_CONVERT(datetime, date+'01'),
             DATEADD(month, 1, TRY_CONVERT(datetime, date+'01')))
FROM yourTable;

```

[Demo
----](https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=85778de39b61d8dfbf56d489503e1d61)

Actually, if you have a long term need for the number of days in each calendar month over some range, you might want to just create a calendar table with this fixed table. Then, you may join to it whenever you need it.
The eomonth() function does the job :)