title: How to pass DateTime parameter in SQL query for Oracle DB
body: <p>I need to include some 'TIMESTAMP' fields in SQL-query WHERE clause:</p>
  
  <pre><code>SELECT * FROM PERSON WHERE PSN_CREATED_DATE &gt;= :createdPrior
  </code></pre>
  
  <p>In my code, <em>createdPrior</em> parameter is defined in the following way</p>
  
  <pre><code>...
  command.Parameters.Add(":createdPrior", Miscellaneous.convertToOracleTimeStamp(createdPrior));
  ...
  
  static class Miscellaneous
  {
      public static OracleTimeStamp convertToOracleTimeStamp(DateTime dateTime)
      {
          OracleTimeStamp result = new OracleTimeStamp(dateTime);
          return result;
      }
  }
  </code></pre>
  
  <p>And as a result I receive a following exception</p>
  
  <blockquote>
    <p>Exception: Additional information: ORA-00932: inconsistent datatypes:
    expected TIMESTAMP got NUMBER</p>
  </blockquote>
  
  <p>Could you tell me, how to pass DateTime in SQL-query for Oracle DB?</p>
  
  <p>P.S.
  What I've tried:
  -I've created an Oracle Parameter with characteristics</p>
  
  <pre><code>OracleParameter para = new OracleParameter();
  para.ParameterName = ":createdPrior";
  para.Direction = System.Data.ParameterDirection.Input;
  para.OracleDbType = OracleDbType.TimeStamp;
  para.Value = Miscellaneous.convertToOracleTimeStamp(createdPrior);
  </code></pre>
  
  <p>-I've passed just DateTime. And I've received another exception</p>
  
  <p>-I've tried to convert parameter to DATE type (using to_date() method), but in this case it seems that I'm loosing minutes and seconds</p>