title: C# Windows Forms MS-Chart control min and max
body: <p>I have a DateTimePicker when selecting time, it calls a SQL stored procedure, a daily average of the points made ​​in that day,
  The problem is that when I give the minimum and maximum values do not appear to me, and if I do not put the maximum and minimum values occur but the date is wrong, the  minimum  is s <code>00:00.00 29/12/1989</code> and the maximum is <code>23/01/1900 00: 00.00</code>
  I do not appear for the selected date values​​, I appears that data from the past.
  That is the portion of code:</p>
  
  <pre><code>#region Day
  private void check_Day_CheckedChanged(object sender, EventArgs e)
        {
          try
          {
              if (check_Day.Checked == true)
              {
                  chartHistory.DataSource = null;
                  chartHistory.DataBind();
                  checkShift.Enabled = false;
                  check_Month.Enabled = false;
                  check_TimePeriod.Enabled = false;
                  dateTimePicker_day.Enabled = true;
                  EventHandler Delegate_dateTimePicker_day = null;
                  Delegate_dateTimePicker_day = delegate(System.Object o, System.EventArgs ee)
                  {
                      string data = dateTimePicker_day.Value.ToShortDateString();
                      chartHistory.ChartAreas[0].AxisX.LabelStyle.Format = "dd/MM/yyyy HH:mm:ss";
                      chartHistory.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Hours;
                      /*
                     var date = DateTime.Parse(data.ToString());
                     DateTime comp = Convert.ToDateTime(date.ToCustomFormat());
                     Console.Write(comp.ToString());
                     */
                     DateTime date_one = Convert.ToDateTime(data.ToString());
                     TimeSpan ts_one = new TimeSpan(00,00,00);
                     DateTime compDate_one = date_one.Date + ts_one;
                     DateTime date_two = Convert.ToDateTime(data.ToString());                        
                     TimeSpan ts_two = new TimeSpan(23, 59, 59);
                     DateTime compDate_two = date_two.Date + ts_two;
                     objConnect = new DatabaseConnection();
                     objConnect.SQL_Param_Date = data;
                     objConnect.ProcedureSql = "[dbo].[sp_DayAverage_Chart]";
                     ds = objConnect.GetConnection;
                     chartHistory.DataSource = ds.Tables[0];
                     chartHistory.DataBind();
                     //double min = compDate_one.ToOADate();
                     //double max = compDate_two.ToOADate();
                     chartHistory.ChartAreas[0].AxisX.Minimum = compDate_one.ToOADate();
                     chartHistory.ChartAreas[0].AxisX.Maximum = compDate_two.ToOADate();
                     chartHistory.ChartAreas[0].AxisX.Interval = 1;
                     Console.Write("Second Data:" + data + "\n");
                     Console.Write("Datetime date_one:" + date_one.ToString() + "\n");
                     Console.Write("Compose Date:" + compDate_one + "\n");
                     Console.Write("Datetime date_two:" + date_two.ToString() + "\n");
                     Console.Write("Compose Date Two:" + compDate_two + "\n");
                     Console.Write("Min:" + compDate_one + "\n");
                     Console.Write("Max:" + compDate_two + "\n");
                  };
                  dateTimePicker_day.ValueChanged += Delegate_dateTimePicker_day;
              }
              else
              {
                  checkShift.Enabled = true;
                  check_Month.Enabled = true;
                  check_TimePeriod.Enabled = true;
                  dateTimePicker_day.Enabled = false;
              }
          }
          catch (Exception err)
          { 
              MessageBox.Show(err.ToString());
          } 
      }
  </code></pre>
  
  <p>Update Post:</p>
  
  <p>Example:
  When you select a date in DateTimePicker (eg 06/05/2014) Format
  double min = 41795.0 (06/05/2014 00:00.00), and double max = 41795.999988425923 (06/05/2014 23:59:59) but in this interval time displays nothing </p>
  
  <p>If I don't set the minimum and maximum at  the chart my X axis it's start from 29/12/1898 00:00.00 and it's end at 23/01/1900 00:00.00</p>