title: sending DATETIME parameters to SP from Method Call In C# Dapper
body: <p>I have following SP in SQL Server</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[SPGetData] 
  
         @StartDate DATETIME,
         @EndDate DATETIME
  
  AS
              BEGIN
                    SELECT *
                    FROM SampleTable
                    WHERE CAST(SampleTable.CreateDate AS DATE) BETWEEN  CAST(@StartDate AS DATE) AND CAST(@EndDate AS DATE)                   
              END
  END
  GO
  </code></pre>
  
  <p>When I test this SP from Management Studio this is working fine , But I should Pass  StartDate and EndDate  values as following</p>
  
  <p><a href="https://i.stack.imgur.com/sRoR9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sRoR9.png" alt="enter image description here"></a></p>
  
  <pre><code>DECLARE @return_value int
  
  EXEC    @return_value = [dbo].[SPGetStationData]
          @StartDate = N'2016/10/08',
          @EndDate = N'2016/10/09'
  
  SELECT  'Return Value' = @return_value
  
  GO
  </code></pre>
  
  <p>I want to send parameters from my back end c# program , </p>
  
  <p>So created method as following</p>
  
  <pre><code>    public IEnumerable&lt;ModelClass&gt; GetDetails(DateTime? startdate, DateTime? enddate)
      {
          using (SqlConnection cnn = this.OpenConnection())
          {
  
              DynamicParameters parameters = new DynamicParameters();
              parameters.Add("@StartDate", startdate);
              parameters.Add("@EndDate", enddate);
  
              IList&lt;ModelClass&gt; SampleList = SqlMapper.Query&lt;ModelClass&gt;(cnn, "SPGetData", parameters, commandType: CommandType.StoredProcedure).ToList();
  
              cnn.Close();
  
              return SampleList.ToList();
          }
      }
  </code></pre>
  
  <p>But when I debug this I can see values coming to this method as 
  in Following format </p>
  
  <p><a href="https://i.stack.imgur.com/l41NC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l41NC.png" alt="enter image description here"></a></p>
  
  <p>in Stored Procedure asking <code>YYYY/MM/DD</code> format but I have here in <code>DD/MM/YYYY HH:MM:SS AM/PM</code> format</p>
  
  <p>what should I do to do this to acceptable with SP asking format</p>