title: How can I convert a string in the format "YYYYMM" to "MMMYY"?
body: <p>I want to pass values in YYYYMM format such as "201509" to a function and retrieve the human-friendlier "MMMYY" format, such as "Sep 2015".</p>
  
  <p>I thought this might work:</p>
  
  <pre><code>internal static string GetMMMYYFromYYYYMM(String YYYYMMVal)
  {
      string intermediateStr = YYYYMMVal + "01";
      DateTime intermediateDate = Convert.ToDateTime(intermediateStr);
      return intermediateDate.ToString("MMMyy");
  }
  </code></pre>
  
  <p>...but no, it crashes with "<em>String was not recognized as a valid DateTime</em>"</p>
  
  <p>ISTM that the YYYYMMDD format should be grokkable and convertible to a DateTime. What do I need to change?</p>
  
  <h2>UPDATE</h2>
  
  <p>Since I wasn't getting quite what I wanted, I decided to "brute force it" like so:</p>
  
  <pre><code>internal static string GetMMMYYFromYYYYMM(String YYYYMMVal)
  {
      string yearAsTwoChars = YYYYMMVal.Substring(2, 2);
      string threeCharAbbreviation = YYYYMMVal.Substring(4, 2);
      if (threeCharAbbreviation.Equals("01"))
      {
          threeCharAbbreviation = "Jan";
      }
      else if (threeCharAbbreviation.Equals("02"))
      {
          threeCharAbbreviation = "Feb";
      }
      else if (threeCharAbbreviation.Equals("03"))
      {
          threeCharAbbreviation = "Mar";
      }
      else if (threeCharAbbreviation.Equals("04"))
      {
          threeCharAbbreviation = "Apr";
      }
      else if (threeCharAbbreviation.Equals("05"))
      {
          threeCharAbbreviation = "May";
      }
      else if (threeCharAbbreviation.Equals("06"))
      {
          threeCharAbbreviation = "Jun";
      }
      else if (threeCharAbbreviation.Equals("07"))
      {
          threeCharAbbreviation = "Jul";
      }
      else if (threeCharAbbreviation.Equals("08"))
      {
          threeCharAbbreviation = "Aug";
      }
      else if (threeCharAbbreviation.Equals("09"))
      {
          threeCharAbbreviation = "Sep";
      }
      else if (threeCharAbbreviation.Equals("10"))
      {
          threeCharAbbreviation = "Oct";
      }
      else if (threeCharAbbreviation.Equals("11"))
      {
          threeCharAbbreviation = "Nov";
      }
      else if (threeCharAbbreviation.Equals("12"))
      {
          threeCharAbbreviation = "Dec";
      }
      return string.Format("{0} {1}", threeCharAbbreviation, yearAsTwoChars);
  }
  </code></pre>
  
  <p>...and, though it returns what I want "Sep 15", "Oct 15" etc., I still see "15-Sep" and "Oct-15" on my page...?!?</p>
  
  <p>I'm calling that helper method like so:</p>
  
  <pre><code>var monthYearCell = _xlPivotDataSheet.Cells[_lastRowAddedPivotTableData + 1, 4];
  monthYearCell.Value2 = ReportRunnerConstsAndUtils.GetMMMYYFromYYYYMM(MonthYear);
  </code></pre>
  
  <p>I reckon Excel must be "autocorrecting" behind the scenes or something; reminds me of a movie I saw ("Reds" maybe?) where the protagonist went semi-ballistic when his editor changed what he wrote. I often feel this way about Word and Excel. How can I tell Excel (assuming this is the problem) to just leave it alone - "What I have written, I have written"?</p>