Assuming that
monthyear
is a DateTime (and it looks like it is from your example) pass it through as a Parameter instead of converting it at all:
cmd.CommandText = string.Format("[dbo].[search_PIValue] {0},@MY", kpi);
cmd.Parameters.AddWithValue("@MY", monthyear);
SQL should then sort it all out itself.