title: How to edit a asp.net chart X Axis label and only show date and not time
body: <p><a href="https://i.stack.imgur.com/Kc5QH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kc5QH.png" alt="enter image description here"></a></p>
  
  <p>How do I remove the time from the X Axis in my chart.
  My sql returns date only but my code adds the time again. </p>
  
  <p>I have tried:</p>
  
  <p><code>Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "##-##-##";</code></p>
  
  <p>But no luck. </p>
  
  <p>My current code:</p>
  
  <pre><code>            Chart1.Visible = ddlChart.SelectedValue != "";
              string query = string.Format(stest);
              DataTable dt = GetData(query);
              string[] x = new string[dt.Rows.Count];
              int[] y = new int[dt.Rows.Count];
              for (int i = 0; i &lt; dt.Rows.Count; i++)
              {
                  x[i] = dt.Rows[i][0].ToString();
                  y[i] = Convert.ToInt32(dt.Rows[i][1]);
              }
              Chart1.Series[0].Points.DataBindXY(x, y);
  
              Chart1.Series[0].ChartType = SeriesChartType.Bar;
              Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
              Chart1.Legends[0].Enabled = true;
  </code></pre>
  
  <p><strong>WORKING CODE</strong> - Thanks jstreet</p>
  
  <pre><code>Chart1.Visible = ddlChart.SelectedValue != "";
              string query = string.Format(stest);
              DataTable dt = GetData(query);
  
              DateTime[] x = new DateTime [dt.Rows.Count];
              int[] y = new int[dt.Rows.Count];
              for (int i = 0; i &lt; dt.Rows.Count; i++)
              {
                  x[i] = Convert.ToDateTime(dt.Rows[i][0]);
                  y[i] = Convert.ToInt32(dt.Rows[i][1]);
              }
              Chart1.Series[0].Points.DataBindXY(x, y);
  
              Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "MM-dd-yyyy";
  
              Chart1.Series[0].ChartType = SeriesChartType.Bar;
  
              Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
  
              Chart1.Legends[0].Enabled = true;
  </code></pre>