title: Search Stored Procedure (SQL Server) -- Conversion failed when converting date and/or time from character string -- Simple?
body: <p>I have a stored procedure that I pass 3 variables <code>bankNumber</code>, <code>branchNumber</code> and <code>DateFrom</code> to. </p>
  
  <p>Based on these variables I want to query the table (seen in picture below stored procedure) to return all records that meet the criteria I pass (through variables). </p>
  
  <p>Instead I am getting this error: </p>
  
  <blockquote>
    <p>Conversion failed when converting date and/or time from character string</p>
  </blockquote>
  
  <p>It seems to be failing when I pass it the <code>DateFrom</code> variable. </p>
  
  <p>Thank you for your help</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[Search_Records] 
      @bankNumber varchar(3),
      @branchNumber varchar(3),
      @dateCreated datetime
  AS
  BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;
  
      -- Insert statements for procedure here
      DECLARE 
          @Bank_Number varchar(3) = @bankNumber,
          @Branch_Number varchar(3) = @branchNumber,
          @DateFrom datetime = @dateCreated,
          @DateTo datetime = @dateCreated
  
      SELECT DISTINCT     
          A.bankNumber, 
          A.branchNumber, 
          A.dateCreated
      FROM        
          dbo.CENSORED A
      WHERE
          (@Branch_Number IS NULL OR bankNumber LIKE @BankNumber + '%')
          AND (@Branch_Number IS NULL OR branchNumber LIKE @Branch_Number + '%')
          AND (@DateFrom IS NULL OR dateCreated LIKE + @DateFrom + '%')
          AND (@DateTo IS NULL OR dateCreated LIKE + @DateTo + '%')
    END
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/vIDCu.jpg" alt="enter image description here"></p>