title: Getting a Date value from Oracle Stored Procedure using ODP.NET
body: <p>I am hoping this is a simple one, as this is my first WPF with Oracle 11g (version 11.2). application.</p>
  
  <p>I am able to call an Oracle stored procedures from my WPF application code and retrieve the  output (int and string) parameters, however when I try to retrieve a date value, I just get the following value <code>01/01/0001 00:00:00</code> which suggests a date is not actually being returned?</p>
  
  <p>The stored procedure works fine in Oracle, i.e. it returns the date. </p>
  
  <p>Here's my code:</p>
  
  <pre><code>string sql = "pkge_intautotest.ScheduleNextRun";
  OracleCommand cmd = new OracleCommand(sql, conn);
  cmd.BindByName = true;
  cmd.CommandType = System.Data.CommandType.StoredProcedure;
  
  DateTime outSchedDateTime;
  cmd.Parameters.Add("outSchedDateTime", OracleDbType.Date, ParameterDirection.Output);
  
  cmd.ExecuteNonQuery();
  
  //Get the values output by the stored procedure
  outSchedDateTime = (DateTime)cmd.Parameters["outSchedDateTime"].Value;
  
  conn.Close();
  conn.Dispose();
  </code></pre>
  
  <p>And here's my (simplified) stored procedure:</p>
  
  <pre><code>PROCEDURE ScheduleNextRun (inIntno NUMBER, outCaseno OUT NUMBER, outSchedDateTime OUT DATE ) AS
  BEGIN
      DECLARE
          sched_datetime DATE;
          init_diary_id DIARY.ID%TYPE;
          v_proceed PLS_INTEGER;
  
      BEGIN
          -- Get the schedule time for 4 minutes from now
          SELECT TO_DATE(SYSDATE + 4/(24*60)) INTO sched_datetime FROM dual;
          outSchedDateTime := sched_datetime;
  
      END;
  END ScheduleNextRun;
  </code></pre>
  
  <p>I will continue looking at this, but any ideas what I am doing wrong?</p>