title: How to convert date format from yyyy-mm-dd to dd MMM yyyy
body: <p>I'm a beginner in C#.I'm facing difficulty in converting date format</p>
  
  <p><strong>I want to convert the date format 2020-02-02 to 02 Mar 2020</strong></p>
  
  <p>I wrote the below function in c#,but it is very lengthy code </p>
  
  <p>Is there any built-in function available in c# to reduce code</p>
  
  <p>Is there a simple way to do this?</p>
  
  <pre><code>public string ConvertToOutputDate(string input) {
      // 2020-02-02
      string year = input.Substring(0, 4);
      string month = input.Substring(5, 2);
      string day = input.Substring(8, 2);
  
      string overall = day;
  
      switch (month) {
      case("01"):
          overall += " Jan";
          break;
      case ("02"):
          overall += " Feb";
          break;
      case ("03"):
          overall += " Mar";
          break;
      case ("04"):
          overall += " Apr";
          break;
      case ("05"):
          overall += " May";
          break;
      case ("06"):
          overall += " Jun";
          break;
      case ("07"):
          overall += " Jul";
          break;
      case ("08"):
          overall += " Aug";
          break;
      case ("09"):
          overall += " Sep";
          break;
      case ("10"):
          overall += " Oct";
          break;
      case ("11"):
          overall += " Nov";
          break;
      case ("12"):
          overall += " Dec";
          break;
      default:
          throw new Exception("&gt; That Month doesn't Exist!: " + month);
      }
      overall += " " + year;
  
      return overall;
  }
  }
  </code></pre>