I was not able to repeat it with a single select from a table with a datetime column.
But it seems that you want to reduce the timestamp to year and month on the format YYYY-MM. A simple way to do that is
convert(char(7), LogTime, 121)
Try that and see what happens. If nothing else, the code will be slender.