title: Tedious SQL Server TVP : parameter.value.getTime is not a function for datetime
body: <p>I am trying to use TVP with tedious and keep getting this error while using a <code>DateTime</code> parameter.</p>
  
  <p>The exception while building the request is :</p>
  
  <pre><code> days = Math.floor((parameter.value.getTime() - UTC_EPOCH_DATE.getTime()) /
   (1000 * 60 * 60 * 24));
                                               ^
  </code></pre>
  
  <p>Exception:</p>
  
  <blockquote>
    <p>TypeError: parameter.value.getTime is not a function</p>
  </blockquote>
  
  <p>The code looks like this </p>
  
  <pre><code>/*declare table*/``    
  let table = {
          columns: [
              { name: 'a', type: TYPES.VarChar, length: 50, nullable: true },
              { name: 'b', type: TYPES.Int},
              { name: 'c', type: TYPES.DateTime}
  
          ],
          rows: [
             ['hello tvp', 777,'05/08/07 12:35 PM'],
             ['OLO', 45,'05/08/16 1:30 AM']
          ]
      };
  
  /*request code*/
  var request = new Request("MyCustomStoredProcedure", function (err, rowCount) {
                      if (!err) {
                          callback(err)
                          logger.info("rowCount", rowCount)
                      } else {
                          callback(rowCount)
                          logger.error("Error =&gt; ", err)
                      }
                  });
                  request.addParameter('tvp', TYPES.TVP, table);
  
                  request.on('row', function (columns) {
                       logger.info("data", columns)
                  });
  
                  connection.callProcedure(request);
  
  
  
  CREATE TYPE TestType AS TABLE (a VARCHAR(50), b INT, c DateTime);
  
  CREATE PROCEDURE MyCustomStoredProcedure 
      (@tvp TestType readonly) 
  AS 
      SELECT * 
      FROM @tvp
  </code></pre>
  
  <p>Looking at the tedious code for data-types.js I found that the <code>parameter.value</code> was a string and not an object .</p>
  
  <p>Not sure what am I doing wrong here. </p>
  
  <p>What I tried</p>
  
  <ul>
  <li>without <code>datetime</code> - works</li>
  <li>with <code>DateTime2</code> - the incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 2 (""): Data type 0x03 is unknown.</li>
  <li>With <a href="https://github.com/patriksimek/node-mssql" rel="nofollow">https://github.com/patriksimek/node-mssql</a>, but internally it again uses Tedious</li>
  </ul>