title: DateTime Parameters in MVC
body: <p>I'm working on a program where I am sending a <code>DateTime</code> variable to a sortable jQuery DataTable.
  This is the constructor in my "Model" file:</p>
  
  <pre><code> public StudentDailyStatus(int studentID, DateTime startDate, DateTime endDate, string code, string status, int goodDays, int badDays, int leave, int lengthOfStay)
  </code></pre>
  
  <p>And then here are the values that I am trying to put into the object:</p>
  
  <pre><code> new StudentDailyStatus(1, (2015, 1, 1), (2015, 2, 1), "1","Normal","2",0,0,0),
  </code></pre>
  
  <p>My error is: "[the file] does not contain a constructor that takes 4 arguments".</p>
  
  <p>But I'm having issues with the <code>startDate</code> and <code>endDate</code> parameters.  How do I use the <code>DateTime</code> variables?
  Thanks for your help!</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web.UI.WebControls;
  using SAAS.Models;
  
  namespace SAAS.Services
  {
      public class StudentDailyStatusService
      {
          private static readonly List&lt;StudentDailyStatus&gt; StudentDailyStatuses;
  
          static StudentDailyStatusService()
          {
              StudentDailyStatuses = new List&lt;StudentDailyStatus&gt;
              {
                  // StudentID, StartDate, EndDate, Code, Status, GoodDays, BadDays, Leave, LengthOfStay
                  new StudentDailyStatus(1, new DateTime(2015, 1, 1), new DateTime(2015, 2, 1), "1","Normal",2,0,0,0),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 3), new DateTime(2015, 1, 4), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 5), new DateTime(2015, 1, 6), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 7), new DateTime(2015, 1, 8), "1","Normal",0,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 9), new DateTime(2015, 1, 10), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 11), new DateTime(2015, 1, 13), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 12), new DateTime(2015, 1, 14), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 15), new DateTime(2015, 1, 16), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 15), new DateTime(2015, 1, 16), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 19), new DateTime(2015, 1, 20), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 21), new DateTime(2015, 1, 22), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 23), new DateTime(2015, 1, 24), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 25), new DateTime(2015, 1, 26), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 29), new DateTime(2015, 1, 31), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 1, 31), new DateTime(2015, 2, 1), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 2, 2), new DateTime(2015, 2, 3), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 2, 4), new DateTime(2015, 2, 5), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 2, 6), new DateTime(2015, 2, 7), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2105, 2, 8), new DateTime(2015, 2, 9), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 2, 10), new DateTime(2015, 2, 11), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 2, 12), new DateTime(2015, 2, 13), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 2, 14), new DateTime(2105, 2, 15), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 2, 16), new DateTime(2015, 2, 17), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 2, 18), new DateTime(2015, 2, 19), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 2, 20), new DateTime(2015, 2, 21), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 2, 22), new DateTime(2015, 2, 23), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 2, 24), new DateTime(2015, 2, 25), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 2, 26), new DateTime(2015, 2, 27), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 2, 28), new DateTime(2015, 3, 1), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 2), new DateTime(2015, 3, 3), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 4), new DateTime(2015, 3, 5), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 6), new DateTime(2015, 3, 7), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 8), new DateTime(2015, 3, 9), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 10), new DateTime(2015, 3, 11), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 12), new DateTime(2015, 3, 13), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 12), new DateTime(2015, 3, 15), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 16), new DateTime(2015, 3, 17), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 18), new DateTime(2015, 3, 19), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 20), new DateTime(2015, 3, 21), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 22), new DateTime(2015, 3, 23), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 24), new DateTime(2015, 3, 25), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 26), new DateTime(2015, 3, 27), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 28), new DateTime(2015, 3, 29), "1","Normal",2,0,0,2),
                  new StudentDailyStatus(1, new DateTime(2015, 3, 30), new DateTime(2015, 4, 2), "1","Normal",2,0,0,2)
              };
          }
  
          public List&lt;StudentDailyStatus&gt; GetStudentDailyStatuses(int start, int length)
          {
              return FilterStudentDailyStatuses().Skip(start).Take(length).ToList();
              //return StudentAllotments.ToList();
          }
  
          public int Count()
          {
              return FilterStudentDailyStatuses().Count();
          }
  
          public IQueryable&lt;StudentDailyStatus&gt; FilterStudentDailyStatuses()
          {
              IQueryable&lt;StudentDailyStatus&gt; results = StudentDailyStatuses.AsQueryable();
  
              return results;
          }
      }
  }
  </code></pre>
  
  <p>And the file that populates the table is:</p>
  
  <pre><code>@{
      ViewBag.Title = "Student - Daily Status";
      ViewBag.SubTitle = "Status History";
  }
  
  @Html.Partial("_StudentNavPartial")
  @Html.Partial("_StudentSearchBar")
  &lt;div class="container-fluid left"&gt;
      &lt;h4&gt;@ViewBag.SubTitle&lt;/h4&gt;
  
      &lt;div class="container-fluid left"&gt;
          &lt;table id="StudentDailyStatusTable" class="table table-striped table-bordered table-hover text-nowrap"&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th data-column="StudentID"&gt;Student ID&lt;/th&gt;
                      &lt;th data-column="StartDate" class="text-center" id="TDtooltip" data-toggle="tooltip" data-placement="bottom" data-original-title="Date Attendance Started" data-container="body"&gt;Start Date&lt;/th&gt;
                      &lt;th data-column="EndDate" class="text-center" id="TDtooltip" data-toggle="tooltip" data-placement="bottom" data-original-title="Date Attendance Ended" data-container="body"&gt;End Date&lt;/th&gt;
                      &lt;th data-column="Code" class="text-left" id="TDtooltip" data-toggle="tooltip" data-placement="bottom" data-original-title="Attendance Status Code" data-container="body"&gt;Code&lt;/th&gt;
                      &lt;th data-column="Status" class="text-center" id="TDtooltip" data-toggle="tooltip" data-placement="bottom" data-original-title="Attendance Status Code" data-container="body"&gt;Status&lt;/th&gt;
                      &lt;th data-column="GoodDays" class="text-center" id="TDtooltip" data-toggle="tooltip" data-placement="bottom" data-original-title="Payable Days for the Student" data-container="body"&gt;Good Days&lt;/th&gt;
                      &lt;th data-column="BadDays" class="text-left" id="TDtooltip" data-toggle="tooltip" data-placement="bottom" data-original-title="Leave Days Paid or Unpaid for the Student" data-container="body"&gt;Bad Days&lt;/th&gt;
                      &lt;th data-column="Leave" class="text-center" id="TDtooltip" data-toggle="tooltip" data-placement="bottom" data-original-title="Leave Days for which the Sudent is Not Paid" data-container="body"&gt;Leave&lt;br /&gt; Status&lt;/th&gt;
                      &lt;th data-column="LengthOfStay" class="text-center" id="TDtooltip" data-toggle="tooltip" data-placement="bottom" data-original-title="Days between Enrollment and Termination" data-container="body"&gt;Length of Stay&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
          &lt;/table&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  @section scripts
  {
      @Scripts.Render("~/bundles/dataTables")
  
      &lt;script type="text/javascript"&gt;
          $.extend($.fn.dataTable.defaults, {
              'pagingType': 'full_numbers',
              'pageLength': 10,
              'language': {
                  'paginate': {
                      'first': '&amp;laquo;',
                      'last': '&amp;raquo;',
                      'previous': '&amp;lsaquo;',
                      'next': '&amp;rsaquo;'
                  },
                  'info': 'Displaying _START_-_END_ of _TOTAL_',
                  'infoEmpty': 'Displaying 0 to 0 of 0',
                  'infoFiltered': '',
                  'search': '',
                  'zeroRecords': 'No matching records found'
              },
              //'dom': '&lt;"top"f&gt;rt&lt;"bottom"&lt;"pull-left"l&gt;&lt;"pull-right"i&gt;p&lt;"clear"&gt;&gt;',
              'dom': '&lt;"top"&gt;rt&lt;"bottom"&lt;"pull-left"l&gt;&lt;"pull-right"i&gt;p&lt;"clear"&gt;&gt;',
              'initComplete': function (settings, json) {
                  $('.dataTables_filter input[type=search]').attr('placeholder', 'Search');
              }
          });
  
          $(function () {
  
              //jQuery(oTable.fnGetNodes()).tooltip({ //tooltip plugin for jQuery!
              //    "delay": 250,
              //    "track": true
              //});
  
              $('#searchButton1').click(function () {
                  var filtering = "";
                  var number = 0;
                  var filterType = "";
                  if ($('#searchSsn').val() != '') {
                      filtering = $('#searchSsn').val();
                  }
                  else if ($('#searchStudentName').val() != '') {
                      filtering = $('#searchStudentName').val();
                      filterType = "Name";
                  }
                  else if ($('#searchStudentID').val() != '') {
                      filtering = $('#searchStudentID').val();
                      filterType = "StudentID";
                  }
                  //Search to get studentID number and count number of results and put into "number"
                  if(number == 1)
                  {
                      //Filter for the one studentID retrieved from the database
                  }
                  else if(number == 0)
                  {
                      //Show the "no results found" window
                  }
                  else
                  {
                      //Multiple results, show the dialog box that will allow the users to choose the correct student
                  }
              });
  
              $('#StudentDailyStatusTable').dataTable({
                  'ajax': {
                      type: 'POST',
                      url: '@Url.Action("GetData", "StudentDailyStatus")',
                      //data: function (d) {
  
                      //}
                  },
                  columns: [
                  {
                      data: 'StudentID',
                      visible: false
                  },
                  {
                      data: 'StartDate',
                      sortable: true,
                      className: "text-center"
                  },
                  {
                      data: 'EndDate',
                      sortable: true,
                      className: "text-center"
                  },
                  {
                      data: 'Code',
                      sortable: true,
                      className: "text-center"
                  },
                  {
                      data: 'Status',
                      sortable: true,
                      className: "text-center"
                  },
                  {
                      data: 'GoodDays',
                      sortable: true,
                      className: "text-center"
                  },
                  {
                      data: 'BadDays',
                      sortable: true,
                      className: "text-center"
                  },
                  {
                      data: 'Leave',
                      sortable: true,
                      className: "text-center"
                  },
                  {
                      data: 'LengthOfStay',
                      sortable: true,
                      className: "text-center"
                  }
                  ],
                  //jQueryUI: true,
                  sort: true,
                  ordering: true,
                  order: [0, 'StartDate'],
                  processing: true,
                  serverSide: true
              });
  
              //$('#TDtooltip').tooltip({
              //    delay: 0,
              //    track: true,
              //    fade: 100
              //});
              //$('td').tooltip({
              //    delay: 0,
              //    track: true,
              //    fade: 100
              //});
              $('[data-toggle="tooltip"]').tooltip({
                  delay: 0,
                  track: true,
                  fade: 100
              });
  
          });
      &lt;/script&gt;
  
  }
  </code></pre>
  
  <p>Okay, here's the controller:</p>
  
  <pre><code>using System;
  using System.Collections;
  using System.Collections.Generic;
  using System.Data;
  using System.Data.Entity;
  using System.Linq;
  using System.Net;
  using System.Web;
  using System.Web.Mvc;
  using SAAS.Models;
  using SAAS.Services;
  
  namespace SAAS.Controllers
  {
      public class StudentDailyStatusController : Controller
      {
  
          // GET: StudentDailyStatus
          public ActionResult DailyStatus()
          {
              return View();
          }
          public JsonResult GetData(DTParameters dtModel, FilterViewModel filterModel)
          {
              try
              {
                  List&lt;StudentDailyStatus&gt; data = new StudentDailyStatusService().GetStudentDailyStatuses(dtModel.Start, dtModel.Length);
                  int count = new StudentDailyStatusService().Count();
                  DTResult&lt;StudentDailyStatus&gt; result = new DTResult&lt;StudentDailyStatus&gt;
                  {
                      draw = dtModel.Draw,
                      data = data,
                      recordsFiltered = count,
                      recordsTotal = count
                  };
                  return Json(result);
              }
              catch (Exception ex)
              {
                  return Json(new { error = ex.Message });
              }
          }
  
      }
  }
  </code></pre>
  
  <p>And here's the "models" file:</p>
  
  <pre><code>using System;
  using System.ComponentModel.DataAnnotations;
  using System.Data.Entity;
  
  namespace SAAS.Models
  {
      public class StudentDailyStatus
      {
          public StudentDailyStatus(int studentID, DateTime startDate, DateTime endDate, string code, string status, int goodDays, int badDays, int leave, int lengthOfStay)
          {
              StudentID = studentID;
              StartDate = startDate;
              EndDate = endDate;
              Code = code;
              Status = status;
              GoodDays = goodDays;
              BadDays = badDays;
              Leave = leave;
              LengthOfStay = lengthOfStay;
          }
  
          [Key]
          public int StudentID { get; set; }
          public DateTime StartDate { get; set; }
          public DateTime EndDate { get; set; }
          public string Code { get; set; }
          public string Status { get; set; }
          public int GoodDays { get; set; }
          public int BadDays { get; set; }
          public int Leave { get; set; }
          public int LengthOfStay { get; set; }
  
      }
  
  }
  </code></pre>